2
我正在嘗試https://github.com/IonicaBizau/tinyreq。看看這些文檔,我使用回調來運行示例沒有任何問題。使用tinyreq與承諾
const tinyreq = require("tinyreq");
// Make a request to example.com
tinyreq("http://example.com/", (err, body) => {
console.log(err || body);
});
但是使用承諾語法沒有給出輸出作爲列出的例子。
// Make a request with custom headers
// Using a promise
tinyreq({
url: "http://example.com/"
, headers: {
"user-agent": "Crawler/1.0"
}
}).then(body => {
console.log(body);
}).catch(err => {
console.log(err);
});
我正在使用節點版本8.3.0。我究竟做錯了什麼?