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

131
Vistas
How to use an API package within ReactJS?

I want to use the package called "youtube-music-api", however I can't get it to work within React. The code resides within a React component that triggers it when the component mounts. The code I used is as follows:

const YoutubeMusicApi = require('youtube-music-api')

function fetchResults(data) {
    const api = new YoutubeMusicApi()
    api.initalize()
    .then(info => {
        api.getSearchSuggestions(data).then(result => {
            console.log(result)
        })
    })
}

However, it ends up failing when I try to run it, I receive the following:

enter image description here

I tried using the package outside of React, and it performed successfully. So, I suspect that the issue may be because with React I am serving the page to the user where they then perform the API call. How might I go about using the package within React?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I suggest using the faker.js package. you can easily get fake data according your use case.

import faker from 'faker'
const [data,setData] = useState([])
useEffect(() => {
var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
var randomCard = faker.helpers.createCard(); // {avatar , name etc..}
setData({ name : randomName , email : randomEmai , card : ...randomCard })
},[]);
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