I've encountered an issue with fetching data from the Tenor API. The URL /random
works on my browser but not within my code.
I know my code is correct because when I tried it with the /search
endpoint, it worked perfectly fine.
Here's the snippet of my current code for the /random
endpoint:
import axios from "axios";
type Result = {
media: Array<{
gif: {
url: string;
};
}>;
};
type Results = {
results: Result[];
};
export default async function getPadoru() {
const res = await axios.get<Results>(
// this URL works on the browser
`https://g.tenor.com/v1/random?q=padoru&key=LIVDSRZULELA&limit=10&media_filter=minimal`
);
await console.log(res);
return await res;
}
This piece of code using the mentioned endpoint returns the following result:
https://i.sstatic.net/Eatpf.png
In contrast, the URL used with the /search
endpoint returns the correct data as expected.
https://g.tenor.com/v1/search?q=padoru&key=LIVDSRZULELA&limit=10&media_filter=minimal