这里是从fetch
收到的响应,其本机反应为0.59。
'response in signup: ', { type: 'default',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: status: 200,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: ok: true,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: statusText: undefined,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: headers:
04-27 11:06:47.426 31991 32031 I ReactNativeJS: { map:
04-27 11:06:47.426 31991 32031 I ReactNativeJS: { connection: 'keep-alive',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: date: 'Sat, 27 Apr 2019 18:06:55 GMT',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: etag: 'W/"3c-2VCbAGm2oGWFDvRizej10F1Ythw"',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: 'content-length': '60',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: 'content-type': 'text/html; charset=utf-8',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: 'x-auth-token': 'ok to proceed',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: 'x-powered-by': 'Express' } },
04-27 11:06:47.426 31991 32031 I ReactNativeJS: url: 'http://192.168.2.133:3000/api/users/signup',
04-27 11:06:47.426 31991 32031 I ReactNativeJS: _bodyInit:
04-27 11:06:47.426 31991 32031 I ReactNativeJS: { _data:
04-27 11:06:47.426 31991 32031 I ReactNativeJS: { size: 60,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: offset: 0,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: blobId: 'd0e4ba3e-2b4a-447e-9344-a81c4ae86c17' } },
04-27 11:06:47.426 31991 32031 I ReactNativeJS: _bodyBlob:
04-27 11:06:47.426 31991 32031 I ReactNativeJS: { _data:
04-27 11:06:47.426 31991 32031 I ReactNativeJS: { size: 60,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: offset: 0,
04-27 11:06:47.426 31991 32031 I ReactNativeJS: blobId: 'd0e4ba3e-2b4a-447e-9344-a81c4ae86c17' } } }
04-27 11:06:47.507 31991 32031 I ReactNativeJS: 'error signing up: ', 'JSON Parse error: Unrecognized token \'?\''
让我感到困惑的是错误:'JSON Parse error: Unrecognized token \'?\'
。
这是应用程序中的获取:
let obj = JSON.stringify({
_device_id: DeviceInfo.getUniqueID(),
cell: cell,
cell_country_code: cell_country_code,
name: username,
corp_name: corp_name,
});
console.log("obj : ", obj);
let res = await fetch(url, {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: obj,
});
此响应来自Nodejs 10.15服务器,返回的数据主体为空。仅设置了标题。
res.set("x-auth-token", "ok to proceed");
return res.status(200).send('Vcode sent out successfully');
我应该从'Accept' : 'application/json'
中删除fetch body
吗? JSON.parser来自何处以及导致错误的原因?