节点获取删除承诺从未解决

时间:2019-09-30 10:22:14

标签: javascript promise node-fetch

我正在运行一个简单的脚本来清理环境。在相当长的一段时间里一直停留在一个看似微不足道的问题上,因此我使用了其他方法,但仍然想知道为什么这在现实中不起作用。 node-fetch GET可以正常工作,但是当我使用DELETE时,什么也不会删除,并且承诺永远也不会解决。

const fetch = require('node-fetch');

var headers = {
    'Content-Type': 'application/json',
    Authorization: `Bearer token-placeholder`
};

fetch(`https://test-api.com/api/entity/123456`, {
    method: 'DELETE',
    headers: headers
})
    .then(res => res.json())
    .then(res => {
        console.log(res)
    })

0 个答案:

没有答案