javascript - 服务器请求中断 Heroku
问题描述
我正在使用 React Native 和 Django。一切正常,直到我提出请求并收到以下错误:
sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/api/obtain-img" host=notarealapp.herokuapp.com request_id=... fwd="..." dyno=web.1 connect=0ms service=22ms status=503 bytes=316 protocol=https
另外,我不知道这是否有用的信息,但我也收到以下错误:
<rest_framework.request.Request: POST '/api/obtain-img'>
我使用的获取代码是这样的:
let token = await SecureStore.getItemAsync("token");
console.log(uri);
let filename = uri.split("/").pop();
let match = /\.(\w+)$/.exec(filename);
let type = match ? `image/${match[1]}` : `image`;
let formData = new FormData();
formData.append("image", { uri: uri, name: filename, type: type });
// formData.append("cateogry", category);
// formData.append("mission", value);
console.log(formData);
return await fetch("https://notarealapp.herokuapp.com/api/obtain-img", {
method: "POST",
headers: {
"content-type": "multipart/form-data",
Authorization: `JWT ${JSON.parse(token)}`,
},
body: formData,
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch((error) => console.error(error));
我的 Django 代码如下:
class ObtainImageUri(APIView):
permission_classes = [IsAuthenticated]
def post(self, request, format=None):
print(request)
return Response({"succes": "The receipt was stored successfully."}, status=200)
我愿意接受任何帮助。
谢谢
解决方案
推荐阅读
- rust - 如何解决 rust 中的“value: ParseIntError”?
- c# - 在统一和节点 js 上对客户端/服务器端使用 RSA 加密/解密
- javascript - 从我得到的响应中反序列化数据
- c - C获取数组的大小
- python - Pandas 中寻找 ID 和旧日期的更快循环
- node.js - Ctrl+C 服务器后运行 npm postscript
- angular - 带有 Angular 8 和 Springboot 2 的 JWT:JWT 字符串必须恰好包含 2 个句点字符
- python - AttributeError 模块 'tensorflow' 在 python 3.7.6 MacOS 中没有属性
- java - 如何在android中用Canvas在一条线的尖端画一个圆圈
- c++ - 单例类不能处理多个文件