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

204
Views
¿Cómo construir una dirección de URL de búsqueda usando dos parámetros dentro?

Quiero enviar una solicitud a Google Books usando fetch para buscar un libro por autor o por título del libro.

No tengo el problema de encontrar libros usando solo un parámetro donde el valor es el título del libro, por ejemplo:

 getData(value) { console.log(value); fetch(`https://www.googleapis.com/books/v1/volumes?q=intitle:${value}&printType=books&${myKey}`) .then(response => response.json()) .then(data => console.log(data)) }

Pero si quiero usar como valor el autor o el título de la URL del libro, funciona mal. Los libros se encuentran solo por autor:

 getData(value) { console.log(value); fetch(`https://www.googleapis.com/books/v1/volumes?q=inauthor:${value}&?q=intitle:${value}&printType=books&${myKey}`) .then(response => response.json()) .then(data => console.log(data)) }

Cómo crear una URL para encontrar los libros, ya sea por autor o por título.

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

0

Necesitas agregar | ( OR ) entre condiciones, aquí tienes:

 https://www.googleapis.com/books/v1/volumes?q=intitle:${value}|inauthor:${value}&printType=books&${myKey}`

Mi consulta de ejemplo:

 https://www.googleapis.com/books/v1/volumes?q=flowers+intitle:david|inauthor:keyes
about 4 years ago · Juan Pablo Isaza Report

0

Dado que desea buscar el autor o el título, ¿no sería más fácil si hace una pequeña condición antes y usa la URL respectiva?

 getValue(value, type){ switch(type){ case "title": fetch(`https://www.googleapis.com/books/v1/volumes?q=intitle:${value}&printType=books&${myKey}`) .then(response => response.json()) .then(data => console.log(data)) break; case "author": fetch(`https://www.googleapis.com/books/v1/volumes?q=inauthor:${value}&printType=books&${myKey}`) .then(response => response.json()) .then(data => console.log(data)) break; } }

type sería lo que desea buscar (en este caso, "autor" o "título").

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!