POSTing JSON with fetch
Në shqip: Dërgimi i JSON me fetch
ShpjegimiSQ
Për të dërguar të dhëna, fetch() merr method: "POST", header-in Content-Type: application/json dhe body me JSON.stringify(). Kontrollo gjithmonë response.ok.
EnglishEN
To send data, fetch() takes method: "POST", the Content-Type: application/json header and a body with JSON.stringify(). Always check response.ok.
Si ta mendosh
Si të dërgosh një letër me adresë, pullë dhe zarf të saktë.
Lexoje në anglisht
Like posting a letter with the right address, stamp and envelope.
Shembull kodijavascript
const r = await fetch("/api/notat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ nota: 5 }),
});