Answer the question
In order to leave comments, you need to log in
How to get JSON from client in ExpressJS?
Here is the AJAX request
const data = {
name: "vasya",
age: 32
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "/sign-in");
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function() {//Call a function when the state changes.
if(xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
};
xhr.send(JSON.stringify(data));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question