How to send POST request with body using http.fetch #4955
-
Hello, when i try to send a fetch POST request to my Express server it throws an Error: I am using SvelteKit and this is my script tag section: <script context="module">
import { goto } from "$app/navigation";
import { fetch } from "@tauri-apps/api/http";
</script>
<script>
let user = {
login: "",
password: "",
};
const handleLogin = () => {
fetch("http://localhost:5000/login", {
method: "POST",
body: JSON.stringify(user),
});
};
</script> I think that |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I guess we should look into manually checking the input type before sending it to rust to get better errors here. |
Beta Was this translation helpful? Give feedback.
-
you can use http.Body.json({}) and so on,you use now maybe a bug |
Beta Was this translation helpful? Give feedback.
body
needs to be an instance of the Body class: https://tauri.app/v1/api/js/classes/http.BodyI guess we should look into manually checking the input type before sending it to rust to get better errors here.