serialize search params
This commit is contained in:
@ -7,8 +7,10 @@ const getRandomResultFromGCI = async (
|
|||||||
if (!query) {
|
if (!query) {
|
||||||
return { error: true, errorMessage: "You must provide a search query." };
|
return { error: true, errorMessage: "You must provide a search query." };
|
||||||
}
|
}
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
searchParams.append("query", query);
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://guncadindex.com/api/releases/?query=${query}`,
|
`https://guncadindex.com/api/releases/?query=${searchParams}`,
|
||||||
);
|
);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error(response.status);
|
console.error(response.status);
|
||||||
@ -19,7 +21,7 @@ const getRandomResultFromGCI = async (
|
|||||||
if (!results || results.length === 0) {
|
if (!results || results.length === 0) {
|
||||||
return {
|
return {
|
||||||
error: false,
|
error: false,
|
||||||
payload: `https://guncadindex.com/search?query=${query}`,
|
payload: `https://guncadindex.com/search?query=${searchParams}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// select a random result from the API
|
// select a random result from the API
|
||||||
|
|||||||
Reference in New Issue
Block a user