Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. export const example = () => async dispatch =>{
  2.  
  3. try {
  4. let rowResponse1 = await fetch('endpoint1', {'attributes': ''});
  5. let response1 = await rowResponse1.json()
  6. if(rowResponse1.status == 200){
  7. await response1.forEach(async (item) => {
  8. let rowResponse2 = await fetch('endpoint2/'+item.att , {'attributes':''});
  9. let response2 = await rowResponse2.json();
  10. item.extraInfo = response2.att;
  11. console.log(response2.att);//log1
  12. });
  13. console.log(response1) //log2
  14. dispatch({'type':'someType', 'payload':response1});
  15.  
  16.  
  17. }else{
  18. //show error
  19. }
  20. }catch(ex){
  21. //manage exception
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement