# Store ranking in JSON format detail view, caching

URL: https://shoptet.dev/news/frontend/store-ranking-in-json-format-detail-view-caching

September 15, 2022 · 2 min read
Pavel Husa

## Introduction

We are happy to announce extension of our JSON formatted page `hodnoceni-obchodu` reffered [here](/news/frontend/store-rating-in-json-format/) . 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` .

## Example

JavaScript – try e. g. on Classic: [https://classic.shoptet.cz/](https://classic.shoptet.cz/)

```javascript
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 older versions of the Safari browser: they do not support `await` directly in the browser console.

Curl

```bash
curl -H "content-type: application/json" -H "X-Store-Rating-Details: true" https://classic.shoptet.cz/hodnoceni-obchodu/
```

## Caching

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.

## Example

In the following example, see `jsonFormat` query in the URL.

```javascript
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));
```

**Tags:**
- [Frontend](/news/tags/frontend/)
