function uploadImage(actionPayload) {
  return (dispatch, getState, sdk) => {
    dispatch(uploadImageRequest(actionPayload));
    processFile(actionPayload.file)
      .then((src) => {
        const options = {
          method: 'POST',
          withCredentials: false,
          body: JSON.stringify({ file: src, id: actionPayload.id, fileType: actionPayload.fileType }),
          headers: {
            "Content-Type": "application/json",
            "X-Api-Key": KEY,
          }
        };
        const url = EVENTS_URL + '/photos';
        fetch(url, options)
          .then(response => response.json())
          .then(data => dispatch(uploadImageSuccess(data.body.id)))
          .catch(response => dispatch(uploadImageError(response)));
      })
  }
}
// Images return imageId which we need to map with previously generated temporary id
Images return imageId which we need to map with previously generated temporary id
Images return imageId which we need to map with previously generated temporary id
function uploadImage(actionPayload) {
  return (dispatch, getState, sdk) => {
    dispatch(uploadImageRequest(actionPayload));
    processFile(actionPayload.file)
      .then((src) => {
        const options = {
          method: 'POST',
          withCredentials: false,
          body: JSON.stringify({ file: src, id: actionPayload.id, fileType: actionPayload.fileType }),
          headers: {
            "Content-Type": "application/json",
            "X-Api-Key": KEY,
          }
        };
        const url = EVENTS_URL + '/photos';
        fetch(url, options)
          .then(response => response.json())
          .then(data => dispatch(uploadImageSuccess(data.body.id)))
          .catch(response => dispatch(uploadImageError(response)));
      })
  }
}
function uploadImage ( actionPayload ) { return ( dispatch , getState , sdk ) => { dispatch ( uploadImageRequest ( actionPayload ) ) ; processFile ( actionPayload . file ) . then ( ( src ) => { const options = { method : 'POST' , withCredentials : false , body : JSON . stringify ( { file : src , id : actionPayload . id , fileType : actionPayload . fileType } ) , headers : { "Content-Type" : "application/json" , "X-Api-Key" : KEY , } } ; const url = EVENTS_URL + '/photos' ; fetch ( url , options ) . then ( response => response . json ( ) ) . then ( data => dispatch ( uploadImageSuccess ( data . body . id ) ) ) . catch ( response => dispatch ( uploadImageError ( response ) ) ) ; } ) } }
Images return imageId which we need to map with previously generated temporary id
Images return imageId which we need to map with previously generated temporary id