We are happy to announce extension of our JSON formatted page hodnoceni-obchodu
reffered here. We discovered that important data are missing, such as scores, average scores, etc.
To ensure backward compatibility, we added an optional header that will modify the display of details. Please compare the following request to the request mentioned in the previous post and change it accordingly. Please see that the former array has moved to an object called ratings
.
JavaScript – try e. g. on Classic: https://classic.shoptet.cz/
const request = await fetch('/cache/hodnoceni-obchodu/', {headers: {'Content-Type': 'application/json', 'X-Store-Rating-Details': 'true'}}); request.json().then(response => console.log(response));
please note that this might not work in the Safari browser. See https://discuss.codecademy.com/t/wanderlust-step-13-safari-browser-console-error-unexpected-identifier-fetch-expected-after-variable-declaration/500899
Curl
curl -H "content-type: application/json" -H "X-Store-Rating-Details: true" https://classic.shoptet.cz/hodnoceni-obchodu/
You’re encouraged to use cache
as much as possible. There is a caveat, though. You get the first cached request, and headers don’t invoke a new caching. So you have to use any query parameter to make the JSON version cached and work with it.
In the following example, see jsonFormat
query in the URL.
const request = await fetch('/cache/hodnoceni-obchodu/?jsonFormat', {headers: {'Content-Type': 'application/json', 'X-Store-Rating-Details': 'true'}}); request.json().then(response => console.log(response));