version 1.54, 2024/03/29 20:59:52 |
version 1.61, 2024/03/29 21:25:18 |
Line 60 async function sendData() { |
|
Line 60 async function sendData() { |
|
const dataToSend = JSON.stringify({"email": "hey@mail.com", "password": "101010"}); |
const dataToSend = JSON.stringify({"email": "hey@mail.com", "password": "101010"}); |
let dataReceived = ""; |
let dataReceived = ""; |
fetch("/feedbk/", { |
fetch("/feedbk/", { |
credentials: "same-origin", |
credentials: "same-origin", |
mode: "same-origin", |
mode: "same-origin", |
method: "post", |
method: "post", |
headers: { "Content-Type": "application/json" }, |
headers: { "Content-Type": "application/json" }, |
body: dataToSend |
body: dataToSend |
}) |
}) |
.then(resp => { |
.then(dataRecieved => response.json()) |
if (resp.status === 200) { |
.then(json => console.log(dataRecieved)) |
return resp.json() |
|
} else { |
|
console.log("Status: " + resp.status) |
|
return Promise.reject("server") |
|
} |
|
}) |
|
.then(dataJson => { |
|
console.log(dataJson); |
|
dataReceived = JSON.parse(dataJson) |
|
}) |
|
.catch(err => { |
|
if (err === "server") return |
|
console.log(err) |
|
}) |
|
console.log(`Received: ${dataReceived}`) |
|
|
|
|
|
}, |
}, |
}); |
}); |