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

Conversation

gtm-nayan
Copy link
Contributor

@gtm-nayan gtm-nayan commented Jul 5, 2022

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:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jul 5, 2022

🦋 Changeset detected

Latest commit: deec568

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-svelte Patch

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

@gtm-nayan gtm-nayan changed the title [create-svelte] [fix] todos failing to delete [create-svelte] [fix] todos failing to edit Jul 5, 2022
@@ -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.

@Rich-Harris Rich-Harris merged commit e9dfe3c into sveltejs:master Jul 5, 2022
@github-actions github-actions bot mentioned this pull request Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create demo app behaviour
3 participants