javascript - 使用 fetch 获取消息正文
问题描述
在 jquery 中,我可以这样做:
$.ajax({
url: "my_sharepoint_site",
type: "post",
headers: {
"accept": "application/json;odata=verbose",
"contentType": "text/xml"
},
success: function(data){
var m = data.d.GetContextWebInformation.FormDigestValue;
}
});
我正在尝试使用 fetch 获取相同的响应数据。
fetch("my_sharepoint_site", {
method: "post",
headers: {
"accept": "application/json;odata=verbose",
"contentType": "text/xml"
}
}).then(function(response){
// response doesn't contain 'd'
});
我似乎无法弄清楚如何获取其余数据。我敢肯定这很简单。
解决方案
您需要探索该.json()
方法:
fetch("my_sharepoint_site", {
method: "post",
headers: {
"accept": "application/json;odata=verbose",
"contentType": "text/xml"
}
})
.then(response => response.json())
.then(data => console.log(data));
推荐阅读
- hadoop - 是否可以将clickhouse数据存储配置为hdfs
- python - 如何在python中实现多个节点的数据包延迟?
- android - 创建平板电脑布局变体与为平板电脑布局创建文件夹之间的区别
- php - PHP:检查管理员是否登录,重定向他们并确保正确的访问
- python-2.7 - 得到错误 {KeyError}
来自scrapy管道中的self.files.pop(spider) - python - 如何修复 PyModbus 无法通过 IME 使用 IF96015 接口解码响应错误
- linux - 使用 bash 计算 Linux 上最小化的窗口
- java - IntelliJ IDEA - 错误:缺少 JavaFX 运行时组件,需要运行此应用程序
- javascript - 在按钮单击 Jade 上调用函数
- angular - 属性 'addToast' 在类型 'GlobalEventHandlers' 角度 5 上不存在