The Google Books API has reached its limit for requests

Encountering a rate limit exceeded error from the Google Books API while using this demo:

To reproduce, open the developer console in Chrome and perform some searches. The rate limit errors will be displayed in the console.

[],"lazyUpdate":null},"status":403,"statusText":"OK","url":"https://www.googleapis.com/books/v1/volumes?q=test","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://www.googleapis.com/books/v1/volumes?q=test: 403 OK","error":{"error":{"errors":[{"domain":"usageLimits","reason":"userRateLimitExceededUnreg","message":"User Rate Limit Exceeded. Please sign up","extendedHelp":"https://code.google.com/apis/console"}],"code":403,"message":"User Rate Limit Exceeded. Please sign up"}}}

This is the search functionality code (Link to the stackblitz book.service):

  onSearch(query: string) {
    this.bookStore.query = query;
    this.query$.pipe(
        filter(Boolean),
        debounceTime(500),
        distinctUntilChanged(),
        tap(async (query: string) => {
          const bo: Observable<Book[]> = this.searchAPI(query);
          const books: Book[] = await bo.toPromise();
          this.bookStore.reset();
          this.bookStore.postA(books);
        })
      )
      .subscribe();

However, this Akita demo does not encounter the same issue:

If anyone knows what could be causing the rate limit exceeded error despite setting debounce time to 500 milliseconds, please share your insights.

Answer №1

This solution resolves the issue:

  constructor(private http: HttpClient) {
      this.bookStore.observeQuery().pipe(filter(Boolean),
        debounceTime(200),
        distinctUntilChanged(),
        tap(async (query: string) => {
          const bo: Observable<Book[]> = this.searchAPI(query);
          const books: Book[] = await bo.toPromise();
          this.bookStore.reset();
          this.bookStore.postA(books);
        })
      )
      .subscribe();
  }

Prior to this, I had the code block above inside of onSearch, which led to a new subscription being created each time onSearch was triggered. Now, the only content within onSearch is this:

  onSearch(query: string) {
    this.bookStore.query = query;
  }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can be taken to prioritize files with specific extensions in webpack?

I have a dilemma with two files: - somefile.scss - somefile.scss.ts When importing the file in my typescript code, it is referencing the wrong one: import styles from "somefile.scss" The typescript part works fine with the correct import (.scss ...

typescript set x and y values to specific coordinates

Trying to map obstacles using a single object. Originally scattered randomly across the map, now I want to hard code X & Y coordinates with an array of numbers. However, TypeScript is only using the last value of the loop for the X coordinate. How can I a ...

Redirecting with PHP after registration using AJAX

My registration form incorporates PHP error checking for issues like a short password. AJAX alerts the user with any errors echoed from PHP. Once the if else statement in PHP is executed, the user is successfully registered and redirected to index.php. he ...

What are some common applications of JSON?

Can you explain the purpose of JSON in Javascript and PHP and when it is necessary to use a JSON method? I checked out the link below but couldn't find any information on how JSON is implemented in actual projects. http://www.json.org/js.html ...

Disabling sound feature in the "mat-video" npm package

Currently, I've implemented the mat-video package (npm i mat-video) in my angular application to facilitate video playback. It's been working quite well. <mat-video style="min-height: 30%" quality="false" title="My Tutorial Title" loo ...

Experience a dynamic D3 geometric zoom effect when there is no SVG element directly underneath the cursor

Currently, I am working on incorporating a geometric zoom feature into my project. You can see an example of what I'm trying to achieve in this demo. One issue I've encountered is that when the cursor hovers over a white area outside of the gree ...

Add a fading transition feature to images that are loaded at a later time

I used a clever technique to create a blur effect by loading a small, lightweight image first. Once the main background image is loaded, it swaps out the 'data-src' with the actual image. However, I am facing an issue with the abrupt transition, ...

VUE- the GetElementByClassName function is malfunctioning

I attempted to utilize 'getelementbyclassname' within VUE methods. My reason for doing so is that instead of applying information using :style, I would like to adjust the width of the div where I applied my class named 'classon'. I ...

TypeScript Type Mapping for HTML Element Tags

I am currently working on a TypeScript + React project and facing an issue with the polymorphic as prop in one of my components. Specifically, I want to restrict this prop to only accept HTML tags, excluding ReactNodes or JSX Elements. Unfortunately, I hav ...

Transmit data via AJAX to the RequestBody

Although seemingly simple, this issue has proven to be quite challenging. I am confident that it can be easily resolved, but the solution continues to elude me. Thank you for any assistance you can provide. Here is the code snippet in question : var samp ...

Using AngularJS Services to Share Objects Between Views and Controllers

I'm finding it difficult to grasp the concept of AngularJS services as I am fairly new to AngularJS. My goal is to pass a nested object between two controllers/views. In my home page partial, I have a section that displays the project and task. hom ...

Experiencing difficulties establishing a connection between the React client and Node.js server using SocketIO

I am currently getting familiar with socketIO and have successfully set up a basic nodejs server. However, I am facing an issue where my nextJS app is unable to connect to the server as expected. Despite no errors being displayed, the messages that should ...

What is the name of the inherited class that invoked the function?

I am looking for a way to determine the name of the class of an object from within a function that called that function. My approach involves utilizing John Resig's class inheritance concept. For instance var CoreStuff = Class.extend({ log: function ...

Configuring the default value for a selection menu in Vue3

Obtaining all available categories: const fetchCategories = async () => { let response = await axios.get(`/api/get_all_category/`) categories.value = response.data.categories } The structure of categories.value is shown here: https://i.sstatic.net ...

What is the best way to horizontally align my divs and ensure they stack properly using media queries?

My layout is not working as expected - I want these two elements to be side by side in the center before a media query, and then stack on top of each other when it hits. But for some reason, it's not behaving the way I intended. I've tried to ce ...

Implementing HTTPS Signed Certificates with IIS on Express for Production Environments

When it comes to managing API (HTTPS) certs in a development environment compared to production in an Express application running on a Node.js/Angular setup deployed to Windows IIS, the process can be a bit confusing. While proxy rewrites have been suggest ...

Issue encountered during frida-il2cpp-bridge module installation

Having trouble with installing the frida module (frida-il2cpp-bridge)? I followed the steps, but encountered errors. You can check out the installation steps here. The specific error message I received is: Spawned `com.games`. Resuming main thread! Refe ...

Discover which references are yet to be resolved within a tsx file

I have been tasked with developing a custom builder for a web application. The challenge now is to automatically detect imports in the code so that the right modules can be imported. My current solution involves traversing the AST of the scripts, keeping ...

Store the link in a variable and retrieve its content into another variable

Is there a way to extract the content of a link stored in a variable and store it in another variable using jQuery or javascript while working on an XML page? I know this is possible with php, but since I am developing a Chrome extension, I am wondering ...

The Typescript intellisense feature in VS Code seems to be malfunctioning

While setting up typings for my Node server, the intellisense suddenly stopped working. I checked my tsconfig.json file: { "version": "0.1.0", "command": "tsc", "isShellCommand": true, "args": ["-p", "."], "showOutput": "silent", " ...