Last active
February 28, 2019 16:54
-
-
Save andreibabor/e5904cfe2a4115612060b38cfa5eac63 to your computer and use it in GitHub Desktop.
Shopify display Yotpo Reviews using API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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