[fix] make demo app work without JS #3965
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3952
After the introduction of shadow endpoints, the demo app would throw a "Body returned from shadow endpoint request handler must be a plain object" error when adding a todo with JS disabled. This was because we were returning a Response, not a POJO.
After fixing that issue, I also had to modify the request passed to the api in the
get
handler. When rendering a page in response to a POST, theget
handler is called with a POST request. Since we passed the original request to theapi
method, we were sometimes making a POST request when we needed a GET. By making a new request, we make sure the method is GET in all cases. I added an explanatory comment to the code since it's a little weird.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
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0