Whether I use Got or Axios, neither works. Also, neither allows sending a body/query in a GET request, but I still get errors when I use POST. I’ve gotten one 400 error if that helps at all.
This is my Got code:
(async () => {
try {
const body = await got.post("https://my-repo-name.prismic.io/graphql", {
headers: {
Authorization: process.env.ACCESS_TOKEN,
"Prismic-Ref": "master",
ref: "master",
},
body: `query{
// ...a query that works in the graphql explorer for my repo...
}
`,
responseType: "json",
});
console.log(body.data);
} catch (e) {
console.log(e);
}
})()
Hi @daniel.mon.johns, I’m not sure about this, so I’ll have to pass it over to our @team-tech-support. Someone there will look into this as soon as they are able and get back to you with what they find.
At the end of the day, they are POST’ing the JSON to the server and receiving a response. I wanted to use a lighter solution because I’m using 11ty and not a full SPA.
Are my URL and headers correct at least?
@daniel.mon.johns
I know that the dev team is tracking this. I don’t have an ETA on when they will be able to look into it, but be assured that it is in their queue.
Someone will reach out to you when they pick this up.
We are going to test this with Axios to see if it works. In the meantime, is there any reason you aren’t using the recommended Client for GraphQL queries?
This users website is a good example of how it works: