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

298
Views
Why my api request returns an empty object?

So I use Google Books API in my application, and i make a request do display data in console, but for some reason it returns an empty object, instead of array of books.

Javascript code:

const API_KEY = 'key=<API-KEY>';
const BASE_URL = 'https://www.googleapis.com/books/v1/';
const API_URL = BASE_URL + 'volumes?q=subject:fiction' + API_KEY;

getBooks(API_URL);

function getBooks(url){
    fetch(url).then(res => res.json()).then(data =>{
        console.log(data);
    })
}

Console in browser:

enter image description here

Edit: So I added '&' in the url and it changed, but now it gives 403 error:

{
  "error": {
    "code": 403,
    "message": "Requests from this Android client application \u003cempty\u003e are blocked.",
    "errors": [
      {
        "message": "Requests from this Android client application \u003cempty\u003e are blocked.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

Maybe I got the wrong key? I got it from Google Books credentials, so I thought it should've worked.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You forgot the & sign between the query params, so you need to change

const API_URL = BASE_URL + 'volumes?q=subject:fiction' + API_KEY;

to

const API_URL = BASE_URL + 'volumes?q=subject:fiction&' + API_KEY;

And also revoke this API Key

about 4 years ago · Juan Pablo Isaza Report

0

You sent the key as part of the q value because you forgot an '&'.

const API_URL = BASE_URL + 'volumes?q=subject:fiction&' + API_KEY;
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!