-
-
Notifications
You must be signed in to change notification settings - Fork 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
[create-svelte] [fix] todos failing to edit #5354
Conversation
🦋 Changeset detectedLatest commit: deec568 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -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(), |
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 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 method
s.
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.
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.
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.
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.
closes #5350
HTTP methods are case sensitive, the fetch spec makes special considerations for some methods normalizing them to uppercase, but not
PATCH
.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0