Skip to content

Instantly share code, notes, and snippets.

@yerkbn
Created April 16, 2019 10:51
Show Gist options
  • Save yerkbn/59567308e26e0b94d850310c9133c640 to your computer and use it in GitHub Desktop.
Save yerkbn/59567308e26e0b94d850310c9133c640 to your computer and use it in GitHub Desktop.
export async function onResultFetching(img){
return async (dispatch) => {
dispatch(onResultPending())
URL = HOSTS[0]
result_obj = {
result: {
class: 'Loading...'
},
resultLoading: false,
isError: false
}
const data = new FormData();
data.append('file', {
uri: img,
type: 'image/jpeg',
name: 'imageName'
});
try{
let resp = await Axios.post(URL, data, {
headers: {
'accept': 'application/json',
'Accept-Language': 'en-US,en;q=0.8',
'Content-Type': `multipart/form-data; boundary=${data._boundary}`,
}
})
console.log('ACTION_RESULTS_SUCCESS',resp.data)
result_obj.result = resp.data
}catch(error){
console.log('ACTION_RESULTS_ERROR', error)
result_obj.isError = true
}
dispatch(onResultFulfilled(result_obj))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment