JSFiddle - React, Tailwind, and code Playground
by Paul Leech
JavaScript
// Replace ./data.json with your JSON feed
/*
fetch('https://api.yotpo.com/products/VlBQ57ijNkyPfsdl8WZehmsbGyCFS9moXpDfrxyv/yotpo_site_reviews/bottomline')
.then(response => {
return response.json()
})
.then(data => {
// Work with JSON data here
console.log(data)
})
.catch(err => {
// Do something for an error here
})
*/
/*
const response = await fetch('https://api.yotpo.com/products/VlBQ57ijNkyPfsdl8WZehmsbGyCFS9moXpDfrxyv/yotpo_site_reviews/bottomline');
const myJson = await response.json();
console.log(JSON.stringify(myJson));
const Http = new XMLHttpRequest();
const url='https://jsonplaceholder.typicode.com/posts';
Http.open("GET", url);
Http.send();
Http.onreadystatechange = (e) => {
console.log(Http.responseText)
}*/
const Http = new XMLHttpRequest();
const url='https://api.yotpo.com/products/VlBQ57ijNkyPfsdl8WZehmsbGyCFS9moXpDfrxyv/yotpo_site_reviews/bottomline';
Http.open("GET", url);
Http.send();
Http.onreadystatechange = (e) => {
console.log(Http.responseText);
//var respArr = {Http.responseText};
}
const userAction = async () => {
const response = await fetch(url, {
method: 'POST',
body: myBody, // string or object
headers: {
'Content-Type': 'application/json'
}
});
const myJson = await response.json(); //extract JSON from the http response
console.log(myJson);// do something with myJson
}
/*
const url2 = 'https://api.yotpo.com/products/VlBQ57ijNkyPfsdl8WZehmsbGyCFS9moXpDfrxyv/yotpo_site_reviews/bottomline'
const userAction = async () => {
const response = await fetch(url2);
const myJson = await response.json(); //extract JSON from the http response
// do something with myJson
console.log(myJson);
}
*/