I’m working on a project where I need to upload animated GIFs to Giphy using their API. However, every time I try to make the request, I get a 405 Method Not Allowed error and I can’t figure out what’s causing it.
Here’s my current code:
const uploadGif = async (gifData, token) => {
try {
const response = await fetch(`https://upload.giphy.com/v1/gifs?api_key=${token}&file=${gifData}`, {
method: 'POST',
body: JSON.stringify(gifData),
headers: {
'Content-Type': 'image/gif'
}
});
if (response.ok) {
const result = await response.json();
return result;
} else {
console.log('Upload failed');
}
} catch (err) {
console.log('Request error: ' + err);
}
};
I’ve checked the Giphy documentation but I’m still stuck. Has anyone encountered this issue before? Any help would be appreciated.