I'm a trying to use the GraphQL api. My queries work in graphiql, but no where else.
I'm using: https://my-repo-name.prismic.io/graphql
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...
}
allOur_valuess {
edges {
node {
hero
}
}
}
}
`,
responseType: "json",
});
console.log(body.data);
} catch (e) {
console.log(e);
}
})()