Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const example = () => async dispatch =>{
- try {
- let rowResponse1 = await fetch('endpoint1', {'attributes': ''});
- let response1 = await rowResponse1.json()
- if(rowResponse1.status == 200){
- await response1.forEach(async (item) => {
- let rowResponse2 = await fetch('endpoint2/'+item.att , {'attributes':''});
- let response2 = await rowResponse2.json();
- item.extraInfo = response2.att;
- console.log(response2.att);//log1
- });
- console.log(response1) //log2
- dispatch({'type':'someType', 'payload':response1});
- }else{
- //show error
- }
- }catch(ex){
- //manage exception
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement