leadbassist
leadbassist

Reputation: 325

cannot fetch data from jsonplaceholder.typicode.com

I am having trouble getting the data from jsonplaceholder.com

I tried using promise:

fetch('https://jsonplaceholder.typicode.com/users')
  .then(resp => resp.json())
  .then(console.log)

using promise

Then I tried the same thing using async function:

async function fetchUsers() {
  const resp = await fetch('https://jsonplaceholder.typicode.com/users')
  const data = await resp.json()
  console.log(data)
}

fetchUsers()

using async function

Either way, I get an error.

I am studying a course where the tutor had no problem fetching the function using both async and promise:

screenshot from the course lecture

Please help

Upvotes: 0

Views: 3563

Answers (1)

leadbassist
leadbassist

Reputation: 325

@HacKaTun3s's comment worked for me: "You cant fetch from a new tab page. Navigate to google.com and try the same thing again."

Upvotes: 4

Related Questions