To make an HTTP request in JavaScript, you can use the XMLHttpRequest object or the newer fetch() API. Here is an example of how to use XMLHttpRequest: function makeRequest(method, url) {
const xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(xhr.responseText);
} else {
console.error(xhr.statusText);
}
};
xhr.onerror = function() {
console.error(xhr.statusText);
};
xhr.send();
}
makeRequest('GET', '/my-endpoint');