Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda