You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fetch in the svelte action follows the returned redirect automatically (to the get endpoint), after which the page is invalidated and svelte will call the get endpoint again to get the updated data. You can see this in dev tools, with the two GETs hitting the same endpoint.
POST http://localhost:3000/
GET http://localhost:3000/
GET http://localhost:3000/__data.json
I can get around that by adding a redirect: "manual" option to the fetch request in the svelte action, since we don't use the data from the redirect anyway. However, by not following the redirect, you don't get the proper status code of the post request (since it ultimately depends on the page you are redirected to)? Not sure what other implications ignoring the redirect might have ...
The text was updated successfully, but these errors were encountered:
I'm not sure I understand. When JavaScript is on the page it's going to use the action instead so you aren't going to have double fetching of the data. You can read more about page endpoints here sveltejs/kit#3532.
For client-side redirects you can use goto. Here's an example I use in a project. It's not perfect but I plan on doing a series on working with forms and finding answers to some of the questions I got from the series.
Not sure what other implications ignoring the redirect might have
I'm not sure if it's a good idea to change that behavior but thanks for sharing it because I wasn't aware of it. 😄
The fetch in the svelte action follows the returned redirect automatically (to the get endpoint), after which the page is invalidated and svelte will call the get endpoint again to get the updated data. You can see this in dev tools, with the two GETs hitting the same endpoint.
I can get around that by adding a
redirect: "manual"
option to the fetch request in the svelte action, since we don't use the data from the redirect anyway. However, by not following the redirect, you don't get the proper status code of the post request (since it ultimately depends on the page you are redirected to)? Not sure what other implications ignoring the redirect might have ...The text was updated successfully, but these errors were encountered: