version 1.56, 2024/03/29 21:03:44 |
version 1.57, 2024/03/29 21:16:42 |
Line 57 async function sendData() { |
|
Line 57 async function sendData() { |
|
//}); |
//}); |
/* --------------------- */ |
/* --------------------- */ |
//ovar re=""; |
//ovar re=""; |
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(resp => { |
if (resp.status === 200) { |
// if (resp.status === 200) { |
return resp.json() |
// return resp.json() |
} else { |
// } else { |
console.log("Status: " + resp.status) |
// console.log("Status: " + resp.status) |
return Promise.reject("server") |
// return Promise.reject("server") |
} |
// } |
}) |
// }) |
.then(dataJson => { |
// .then(dataJson => { |
console.log(dataJson.get("a")); |
// console.log(dataJson.get("a")); |
// dataReceived = JSON.parse(dataJson.getJSON); |
// dataReceived = JSON.parse(dataJson.getJSON); |
}) |
// }) |
.catch(err => { |
// .catch(err => { |
if (err === "server") return |
// if (err === "server") return |
console.log(err) |
// console.log(err) |
}) |
// }) |
console.log(`Received: ${dataReceived}`) |
//console.log(`Received: ${dataReceived}`) |
|
|
|
fetch('https://draft.hgk.global/feedbk/') |
|
.then(response => response.json()) |
|
.then(json => console.log(json)) |
|
|
|
|
|
|
}, |
}, |
}); |
}); |