Make API call (POST Request) using JavaScript in browser’s debug console

const xhr = new XMLHttpRequest();
const url = "END_POINT";
const data = {};//Request Body


xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        console.log(xhr.responseText);
    }
};
xhr.send(data);


Leave a comment

Your email address will not be published. Required fields are marked *