Guest User

Untitled

a guest
May 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. try {
  2. const response = await fetch(url, {
  3. method: 'GET',
  4. headers: {
  5. 'Content-Type': "application/json",
  6. 'Accept': 'application/json'
  7. }
  8. });
  9. } catch (err) {
  10. console.log(err)
  11. }
  12.  
  13. you need to modify like below
  14.  
  15. fetch(url)
  16. .then((resp) => resp.json()) // Transform the data into json
  17. .then(function(data) {
  18. // your code logic with the response
  19. })
  20. })
Add Comment
Please, Sign In to add comment