hola estoy tratando de subir un video a giphy mediante la api pero siempre obtengo estos errores, alguien sabe que significan:
mis_guifos.html:1 Access to fetch at 'http://upload.giphy.com/v1/gifs/?&api_key=x58Cq33OnTiwdQ7gRoG1bsCNVFJdEX1d' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
mis_guifos.js:245 POST http://upload.giphy.com/v1/gifs/?&api_key=x58Cq33OnTiwdQ7gRoG1bsCNVFJdEX1d net::ERR_FAILED
mis_guifos.js:248 Uncaught (in promise) TypeError: Failed to fetch
Éste es mi código (no sé si la cabecera está bien escrita):
form = new FormData();
form.append('file', recorder.getBlob(), 'myGif.gif');
file = form.get('file');
btn_upload_gif.addEventListener("click", function() {
var new_header = new Headers();
var options = {
method: "POST",
mode: "cors",
headers: new_header,
cache: "default",
body: file,
headers: {
"content-type": "video/ogg"
}
}
async function uploading_gif(url) {
let gif_file = await fetch(url, options);
let gif_file_json = await gif_file.json();
console.log(gif_file_json);
}
uploading_gif(`http://upload.giphy.com/v1/gifs/?&api_key=x58Cq33OnTiwdQ7gRoG1bsCNVFJdEX1d`);
});
fetch
para hacer todos los tipos de solicitudes HTTP que existen. Yo revisaría el comentario. Saludos.