Skip to content

Instantly share code, notes, and snippets.

@andreibabor
Last active February 28, 2019 16:54
Show Gist options
  • Save andreibabor/e5904cfe2a4115612060b38cfa5eac63 to your computer and use it in GitHub Desktop.
Save andreibabor/e5904cfe2a4115612060b38cfa5eac63 to your computer and use it in GitHub Desktop.
Shopify display Yotpo Reviews using API
var data = JSON.stringify(false);
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
var test = this.responseText;
var json = JSON.parse(test);
console.log(json);
var rez = json.response.bottomline.average_score;
document.getElementById("h1").innerHTML = rez;
}
});
xhr.open("GET", "https://api.yotpo.com/v1/widget/{{API-KEY}}/products/371907935/reviews");
xhr.send(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment