Skip to content

Axios and Fetch API error [ OBJECT PROMISE ] #9740

Answered by rigor789
bobwatcherx asked this question in Q&A
Discussion options

You must be logged in to vote

See https://developer.mozilla.org/en-US/docs/Web/API/Response/json

.json() returns a Promise, so the output is correct. You need to wait for it to resolve:

fetch("https://httpbin.org/get")
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.log('err', err))

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rigor789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #9739 on January 16, 2022 13:29.