获取polyfill,未定义的PromiseValue
Fetch polyfill, undefined PromiseValue
试图使用fetch polyfill使DELETE
请求,但我得到Uncaught TypeError: Cannot read property 'then' of undefined
,这是promise.then()
上的错误
我是这样做的:
function deleteData(item, url) {
fetch(url + '/' + item, {
method: 'delete'
}).then(response => {
return response.json();
});
}
另一方面,当我做/GET
请求时,一切工作正常:
function fetchData(url) {
return fetch(url).then(response =>
response.json().then(json => {
return json;
})
);
}
你知道我做错了什么吗?
你必须返回承诺:
function deleteData(item, url) {
return fetch(url + '/' + item, {
method: 'delete'
}).then(response => {
return response.json();
});
}
相关文章:
- 未捕获的类型错误:无法读取属性'fitBounds'谷歌地图(markrWithlabel js)中未定
- emscripten+sdl=引发异常:TypeError:无法设置属性'widthNative'的未定
- ExceptionsManager.js:61无法读取属性'getCurrentPosition'的未定
- 未捕获的ReferenceError:未定义项
- 为什么我会得到错误Uncaught TypeError:无法设置属性'显示'在Javascript中未定
- 找不到未定错误的属性长度
- JSON 对象中的未定义项
- 未捕获的ReferenceError:未定义父级
- 当使用window.open将数据从父级传递到子级时,为什么我会得到'无法读取属性'元素'的未定
- 如何在dojo或JavaScript中检查多个未定义项
- 防止在一行代码中出现未定义项
- uncatch TypeError:无法读取 javascript / React-router / React 中未定
- Requirejs + Backbone Uncatch TypeError: 無法讀取未定義的屬性「Model」
- 砌体布局未定心
- 获取polyfill,未定义的PromiseValue
- 为什么我得到'TypeError: Cannot read property 'props'未定