Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Stop API request after first iteration

I am making an API request to google books, and whenever I get a response I want to end the api call. Because, i noticed that when i successfully make a request and map the response, it still makes requests and i get a quota exceeded per minutes error.

See my api.js

I am using superagent

import React, { Component } from "react"
import request from 'superagent';
import BookList from './BookList';

class Book extends Component{
    constructor(props){
      super(props);
      this.state = {
        books: [],
      }
    }
     LoadMyBooks = () => {
       request.
      get("https://www.googleapis.com/books/v1/users/101611817084652232916/bookshelves/4/volumes?key=yourKey")
      .query(null)
      .then((data) =>{
        // console.log(data);
        this.setState({books: [...data.body.items]})
        
      })
    }
    
   
   

    render(){
      const mybooks = this.LoadMyBooks();
      return(
        <div>
              <BookList books={this.state.books}/>
              
        </div>
  
  
      );
    }
    

  }

  export default Book
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

import React, { Component } from "react"
import request from 'superagent';
import BookList from './BookList';

class Book extends Component{
    constructor(props){
      super(props);
      this.state = {
        books: [],
      }
    }
     componentDidMount(){
       request.get("https://www.googleapis.com/books/v1/users/101611817084652232916/bookshelves/4/volumes?key=yourKey")
      .query(null)
      .then((data) =>{
        // console.log(data);
        this.setState({books: [...data.body.items]})
        
      })
    
    }
   
   

    render(){
      
      return(
        <div>
              <BookList books={this.state.books}/>
              
        </div>
  
  
      );
    }
    

  }

  export default Book
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!