POST请求给Giphy API时出现错误405(不允许使用方法)

时间:2020-07-28 21:14:07

标签: javascript api fetch

我正在尝试将从网络摄像头录制的gif发布到Giphy API,但我不断收到此错误“ net :: ERR_ABORTED 405(不允许使用方法)”,但我真的不知道自己在做什么做错了。

fetch(`upload.giphy.com/v1/gifs?api_key=${apiKey}&file=${data}`, {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
      'Content-Type': 'image/gif' 
    }
  })
  .then((res) => {
    if(res.ok){
      return res.json()
    }else{
      console.log("Denied")
    }
  })
  .catch((error) => {
    console.log("Error " + error)
  })

0 个答案:

没有答案