In React, NextJS, following the excellent Leigh Halliday YouTube tutorial: https://www.youtube.com/watch?v=_HOp7hBEjp8 , I want to fetch my data from an external API, instead of having hardcoded local JSON (file src/data.ts )like him:
export const data = {
bio: {
name: "FirstName Surname",
tagline: "Developer",
.
.
}
I'm trying to do something like this (replaces the hardcoded content in src/data.ts):
export const data = async () => {
const res = await fetch ('https://api...link');
console.log('in fetch: res: ' + res);
return res.json();
};
This fetch fails badly, I can see from the browser developer panel. I never see the console log message, but I can see there is something with the fetch. Any ideas? UPDATE: This is the error message:
name: graphql, status: 400, type: fetch, initiator: createHttpLink.js: 76