HTTP Status code 400 [TypeScript]

Making a bot using typescript that fetches a specific api, then sends the info formatted into an embed. i first start off defining headers (don't worry, api key is public)
const options: RequestInit = {
method: 'POST',
headers: {
accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Bearer e2a1974678b37386fef69bb3638a1fb36263b78a8be244c04795ada0fa250d3d'
},
body: JSON.stringify({ q: gameName, limit: 2, page: nextPage })
};
const options: RequestInit = {
method: 'POST',
headers: {
accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Bearer e2a1974678b37386fef69bb3638a1fb36263b78a8be244c04795ada0fa250d3d'
},
body: JSON.stringify({ q: gameName, limit: 2, page: nextPage })
};
which, is basically the same code i've used for my other file, just without the "nextPage".
try {
const fetchPage = await fetch('(api link here)', options);
if (!fetchPage.ok) {
console.log(fetchPage)
console.log(nextPage)
throw new Error(`HTTP error status: ${fetchPage.status}`);
}
try {
const fetchPage = await fetch('(api link here)', options);
if (!fetchPage.ok) {
console.log(fetchPage)
console.log(nextPage)
throw new Error(`HTTP error status: ${fetchPage.status}`);
}
(don't mind the non existent api link, it's there in my code) this just prints out debug info, which, the nextPage looks fine, but the json response is wrong, returning a "[Symbol(realm)]: null,". i am using the meilisearch api to fetch stuff. but, still gives out http status code 400. my other code, that is basically the same thing, fetches just fine. is the issue within "nextPage"?
2 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
joetroll
joetrollOP7mo ago
node version is v20.12.2 oops, nvm, solved
Want results from more Discord servers?
Add your server