Compliments of RapidAPI, this repo serves as a quick reference for different HTTP request options using JavaScript.
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.status === 200) {
console.log(xhttp.responseText);
}
};
xhttp.open("GET", "URL");
xhttp.send();
fetch(URL)
.then( res => {
console.log(res)
})
.catch( err => {
console.log(err)
});
import axios from 'axios';
const requestData = async () => {
try {
const res = await axios.get('API', {
headers: {},
params: {}
});
} catch(err) {
console.log(err);
}
}
$.ajax({
url: 'URL',
type: 'GET',
success: function (response) {
console.log(response);
},
error: function (error) {
console.log(error);
},
});