Requests not hitting API on production
Unanswered
Japanese flying squid posted this in #help-forum
Japanese flying squidOP
So I have that simple function in
Which filters and fetches accordingly in local. However, it is simply not getting any results in production. Here is the production link if you would like to try: https://bookverse-taupe.vercel.app/
/app/books/page.tsx which fetches some data from an API:async function getBooks({
searchParams,
}: {
searchParams: { [key: string]: string };
}): Promise<SearchResult> {
const params = new URLSearchParams(
removeEmptyQueryParams(searchParams)
).toString();
const url = `https://book-finder1.p.rapidapi.com/api/search?${params}`;
console.log(params); // title=lord+of+the+rings&categories=Science+Fiction+%26+Fantasy
const response = await fetch(url, fetchOptions);
const results = await response.json();
return results;
}Which filters and fetches accordingly in local. However, it is simply not getting any results in production. Here is the production link if you would like to try: https://bookverse-taupe.vercel.app/
1 Reply
Japanese flying squidOP
fetchOptions is imported from utils.ts and is following:export const fetchOptions = {
method: "GET",
headers: {
"X-RapidAPI-Key": process.env.API_KEY,
"X-RapidAPI-Host": process.env.API_HOST,
},
};