Skip to content

Commit

Permalink
modify of review points
Browse files Browse the repository at this point in the history
  • Loading branch information
yumiura committed Nov 29, 2023
1 parent 6647da6 commit 51ba305
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/image.js
Expand Up @@ -43,23 +43,30 @@ Object.defineProperty(Image.prototype, 'src', {
throw err
}
}
const request = fetch(url = val, data = {
method: "POST",
headers: { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36' }
})

request.then((res) => {
util
.callbackify(
fetch(val, {
method: 'POST',
headers: {
"User-Agent":
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36",
},
})
)
.then((res) => {
if (res.statusCode < 200 || res.statusCode >= 300) {
return onerror(new Error(`Server responded with ${res.statusCode}`))
return onerror(
new Error(`Server responded with ${res.statusCode}`)
);
}
return res.arrayBuffer()
})
.then((data) => {
return setSource(this, data)
setSource(this, data)
})
.catch((err) => {
return onerror(err)
})
onerror(err);
});
} else { // local file path assumed
setSource(this, val)
}
Expand Down

0 comments on commit 51ba305

Please sign in to comment.