<Button
onClick={async () => {
console.log("log bth clk");
const response = await fetch("http://localhost:3000/login", {
mode: "cors",
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
// credentials: "same-origin",
credentials: "include",
body: JSON.stringify({ username, password }),
});
const headers = response.headers;
const json = await response.json();
if (response.status == 400) {
setErrors(json.errors);
} else {
console.log(json, headers, headers.get("a"));
}
// console.log(errors, json);
}}
>
Login
</Button>
<Button
onClick={async () => {
console.log("log bth clk");
const response = await fetch("http://localhost:3000/login", {
mode: "cors",
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
// credentials: "same-origin",
credentials: "include",
body: JSON.stringify({ username, password }),
});
const headers = response.headers;
const json = await response.json();
if (response.status == 400) {
setErrors(json.errors);
} else {
console.log(json, headers, headers.get("a"));
}
// console.log(errors, json);
}}
>
Login
</Button>