0

I used Node, Express and MongoDB to create simple API that should allow me get JSON data, next I deployed it on Heroku.

Whenever I tried to fetch it (locally or using Heroku link), I received this error: Uncaught (in promise) TypeError: Failed to fetch This is my code:

async function fetchFlats () {
const res = await fetch("https://rocky-basin-55272.herokuapp.com/");
const data = await res.json();
console.log(data);
}
fetchFlats()
AndSzy
  • 23
  • 4
  • Read the **other** error messages, not just the last one. – Quentin May 01 '20 at 14:45
  • @Quentin Thank you. The link that you provided was a good read and pointed me in the right direction. I used [cors - npm](https://www.npmjs.com/package/cors) and everything works fine. – AndSzy May 01 '20 at 15:27

0 Answers0