BFP
BFP

Reputation: 126

how to fix networkerror when fetching an api?

I'm trying to fetch an Api, but it keeps telling me there is a network error and I cant find a way anywhere to fix it.

const atlasApi = `Access-Control-Allow-Origin: https://atlas-obscura-api.herokuapp.com/api/atlas/destinations`
fetch(atlasApi).then(response => {
  return response.json()
}).then(data => {
  console.log(data)
})

Upvotes: 0

Views: 39

Answers (1)

Vivek Verma
Vivek Verma

Reputation: 551

Your api url seems incorrect, please try removing Access-Control-Allow-Origin: from the atlasApi. Then it should work fine.

Upvotes: 1

Related Questions