【发布时间】:2021-05-26 00:46:28
【问题描述】:
我需要通过网址下载照片。我使用获取 API。我尝试了 cors 和 no-cors。
我想我一般不理解“http”中的某些内容(标题或其他内容)。
这是我的代码:
const options = {
method: 'GET',
mode: 'cors',
};
fetch('https://artlight.ru/upload/iblock/a47/ART-1013 size13.jpeg', options)
.then((response: any) => {
console.log(response);
response.blob();
})
.then((blob: any) => {
console.log(blob);
})
无论我做什么,我都会得到相同的响应:
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]:
{ body:
PassThrough {
_readableState: [ReadableState],
readable: true,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: true,
_transformState: [Object] },
disturbed: false,
error: null },
[Symbol(Response internals)]:
{ url:
'https://artlight.ru/upload/iblock/a47/ART-1013%20size13.jpeg',
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object] },
counter: 0 } }
undefined
我应该怎么做才能得到我的 blob?谢谢!
【问题讨论】:
标签: node.js download fetch blob