node.js - 上传到 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 错误请求
解决方案
推荐阅读
- javascript - 获取无效 POST、PATCH 的 CORS 错误 - REST 端点
- javascript - 在使用 face-api.js 进行人脸检测后,有什么方法可以自动裁剪人脸?
- c# - 使用 C# 和 CMD 定义防火墙
- javascript - jspdf.html 方法不分页(或将内容推送到下一页)
- web-services - 当我尝试使用 Coldfusion Web 服务上传文件时出现 Enctype 问题
- c# - 尝试在 pod/容器中添加证书时出现权限被拒绝错误
- python - 根据字典顺序为字符串 s 分配唯一值
- python - Gemini API Python {'result': 'error', 'reason': 'InvalidSignature', 'message': 'InvalidSignature'}
- laravel - 如何在 laravel livewire 中编辑多个图像上传中的特定图像
- python - 将二进制拆分为 0 和 1 组并获取边界索引