Created
April 16, 2019 10:51
-
-
Save yerkbn/59567308e26e0b94d850310c9133c640 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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