How can I make use of the If-None-Match header in the Google APIs Client Library for JavaScript?

75 Views Asked by At

How can I make use of the If-None-Match header in the Google APIs Client Library for JavaScript? I have written the following code, but even when the ETag remains the same, the response status is always 200. How can I modify it to receive a 304 response when sending the ETag in the request headers and there are no modifications?

...
async unkno() {
    let requestOptions = {
      part: this.part,
      maxResults: this.maxResults,
      myRating: this.myRating,
    };
      if (ETag) {
        
        requestOptions.headers = {
          "If-None-Match": ETag,
        };
      }
    try {
      const data = await gapi.client.youtube.videos.list(requestOptions);
      console.log(data);
      ETag = data.result.etag;
      return data.result;
    } catch (error) {
      throw error;
    }
  }
...
0

There are 0 best solutions below