-
Notifications
You must be signed in to change notification settings - Fork 122
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
feat(hn): update deps, edge based #528
Conversation
PuruVJ
commented
Jul 11, 2023
- Updates deps of hn.svelte.dev
- Switches to using edge runtime for faster performance and less impact on environment
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
export async function load({ params, fetch }) { | ||
const res = await fetch(`https://api.hnpwa.com/v0/user/${params.name}.json`); | ||
return res.json(); | ||
return fetch(`https://api.hnpwa.com/v0/user/${params.name}.json`).then((r) => r.json()); |
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.
making it one line makes sense, but why not use await
still?
return fetch(`https://api.hnpwa.com/v0/user/${params.name}.json`).then((r) => r.json()); | |
return (await fetch(`https://api.hnpwa.com/v0/user/${params.name}.json`)).json(); |
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 dunno, await has felt weird when surrounded by brackets. .then feels cleaner for this case somehow
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.
What happens if invalid JSON is returned from the API? I think the two ways of writing it would behave differently, but I'm not exactly sure what the behavior of the .then()
version is
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.
It's the same. If it errors, then .json() errors out, giving the same error as await version