首页 > 解决方案 > 上传到 imgur api 总是返回状态 400 错误 Nodejs

问题描述

我无法使用 nodejs 将任何图像上传到 imgur
这是我的代码

                    const imgurForm = new FormData();
                    imgurForm.append('image', req.file);
                      axios.post(
                      'https://api.imgur.com/3/upload',
                          imgurForm ,
                      {
                        headers: {
                          Authorization: `Client-ID ${process.env.IMGUR_CLIENT_ID}`,
                          ...imgurForm.getHeaders(),
                        },
                      }
                    )
                    .then((response)=>{
                        res.json(response.data)

                        console.log(response.data);
                   })
                   .catch((err)=>{
                       console.log(err);
                       res.json({"Error": "Unable to change avatar please try again."})
                   })

总是返回错误 400 错误请求

标签: node.jsaxiosimgur

解决方案


推荐阅读