-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace fetch api #2309
base: master
Are you sure you want to change the base?
Replace fetch api #2309
Conversation
I will make sure that the relevant PR is made 👀 |
Thanks, that's a nice change. #2310 will need to land first to drop support for older versions of Node.js. |
This commit is important, Should I separate PR? |
lib/image.js
Outdated
|
||
get.concat({ | ||
url: val, | ||
const request = fetch(url = val, data = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates two new global variables, url
and data
. I'm guessing it was a misstake
const request = fetch(url = val, data = { | |
const request = fetch(val, { |
lib/image.js
Outdated
get.concat({ | ||
url: val, | ||
const request = fetch(url = val, data = { | ||
method: "POST", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use single quotes to align with the rest of the file?
method: "POST", | |
method: 'POST', |
lib/image.js
Outdated
}) | ||
|
||
request.then((res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since request
is only used once, you could chain here and remove the variable:
}) | |
request.then((res) => { | |
}) | |
.then((res) => { |
lib/image.js
Outdated
return res.arrayBuffer() | ||
}) | ||
.then((data) => { | ||
return setSource(this, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setSource
doesn't return anything?
return setSource(this, data) | |
setSource(this, data) |
lib/image.js
Outdated
return setSource(this, data) | ||
}) | ||
.catch((err) => { | ||
return onerror(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
return onerror(err) | |
onerror(err) |
Also, the behaviour of onerror
is that it throws if a handler hasn't been set. Before this change, that thrown was delegated to the global error handler.
Now it will instead be eaten by this promise, which I don't think is desirable.
I think that util.callbackify
or process.nextTick
would be best used to restore the old behaviour 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> 93cfd2f
I'm not sure if the changes I made are correct...
51ba305
to
93cfd2f
Compare
|
lib/image.js
Outdated
util | ||
.callbackify( | ||
fetch(val, { | ||
method: 'POST', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the changes I made are correct.
simple-get.concat method type is GET.
5213c1f
to
a2e3845
Compare
@LinusU I fixed it |
@LinusU This is just a reminder if you missed my commit. Could you please take a look at my commits I’ve done last week and merge it if it looks ok. |
64ed3d8
to
ff0f2ab
Compare
@LinusU Could you please review this PR? ;; |
@zbjornson Could you review, as it seems that @LinusU is busy? |
@LinusU Could you please let me know when the pull request is expected to be merged? |
Sorry for being a bit slow on the feedback here... Looking at the code, I don't think that it works? Have you tested this? |
Use fetch api and remove simple-get depedency (context: #2223 (comment)).