Skip to content
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

[create-svelte] [fix] todos failing to edit #5354

Merged
merged 4 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-terms-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

fix todos fail to update in demo app
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const base = 'https://api.svelte.dev';
*/
export function api(method: string, resource: string, data?: Record<string, unknown>) {
return fetch(`${base}/${resource}`, {
method,
method: method.toUpperCase(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... This makes me uncomfortable. Does undici require uppercase method names while node-fetch didn't? Needing this feels like a workaround, and I'd prefer trying to get to the bottom of what changed rather than fixing it here in the template project. We shouldn't expect everyone using SvelteKit to always be calling their APIs with upper-case methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think it was just patch that was 400-ing, so I didn't consider the switch from node-fetch to undici as a possible cause, but not completely off the table I guess. I'll do a quick sanity check.

Copy link
Contributor Author

@gtm-nayan gtm-nayan Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's only patch that's affected, but looks like it is intended to be case-sensitive whatwg/fetch#50 and Undici being more spec compliant is likely what changed.

We shouldn't expect everyone using SvelteKit to always be calling their APIs with upper-case methods

For spec compliance we'd have to, and all uppercase seems to be the convention at least for the REST verbs. I'll uppercase the verbs on the api(..) calls to make it more explicit rather than tucking it away inside the function definition.

headers: {
'content-type': 'application/json'
},
Expand Down