我正在使用铬devTools镜像一个webRequest。查看网络请求,我想要访问的响应中有一些JSON数据
右击->复制为提取->
fetch(
"https://www.url.com/service.svc?action=FindConversation&ID=-40&AC=1",
{
"credentials":"include",
"headers":{
"accept":"*/*",
"accept-language":"en-US,en;q=0.9",
"action":"FindConversation",
"content-type":"application/json; charset=UTF-8",
"actionid":"-40",
"unique_identifier":"062lCufCY0i5mI9NMTRUsF87XDq9ttYIonzZQjBcCOPvzoIJFOTSI6ZVNK9lMwy_iPFY2tuZzPY."
"x-requested-with":"XMLHttpRequest"
},
"referrer":"https://ballard.amazon.com/OWA/",
"referrerPolicy":"no-referrer-when-downgrade",
"body":"contains some body data I want to manipulate",
"method":"POST",
"mode":"cors"
}
).then(res => {console.log(res)})
这个打印出这样的东西:
Response {type: "basic", url: "https://url/service.svc?action=FindConversation&ID=-40&AC=1", redirected: false, status: 200, ok: true, …}
body: ReadableStream
locked: false
__proto__: ReadableStream
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "basic"
url: "https://url/OWA/service.svc?action=FindConversation&ID=-40&AC=1"
__proto__: Response
当我检查刚才提出的网络请求时,它似乎没有返回任何JSON数据,而是使用200
代码进行响应。这正常吗?
我要么期望它返回JSON数据,要么失败。
另外,JSON响应数据在res
中的位置
发布于 2019-04-01 17:34:12
这是正常的行为。fetch()
返回一个流对象,而不仅仅是主体。
使用res.json()
提取JSON内容。对于非JSON响应,请使用res.text()
https://stackoverflow.com/questions/55460648
复制相似问题