Encontré cómo usar getArtistRelatedArtists pero no sé cómo llamarlo y usarlo para imprimir artistas relacionados.
Hice algo como relArtist = data.artists.item[0].relatedArtist pero estoy bastante seguro de que no hay nada como .relatedArtist
relArtist significa artista relacionado. Obv, aún no lo he impreso, pero no sé por dónde empezar.
var express = require('express'); var app = express(); var SpotifyWebApi = require('spotify-web-api-node'); var spotifyApi = new SpotifyWebApi({ clientId : process.env.CLIENT_ID, clientSecret : process.env.CLIENT_SECRET, }); // Authenticate our app with Spotify spotifyApi.clientCredentialsGrant() .then(function(data) { console.log('The access token expires in ' + data.body['expires_in']); console.log('The access token is ' + data.body['access_token']); // Save the access token so that it's used in future calls spotifyApi.setAccessToken(data.body['access_token']); }, function(err) { console.log('Something went wrong when retrieving an access token', err.message); }); // http://expressjs.com/en/starter/static-files.html app.use(express.static('public')); // http://expressjs.com/en/starter/basic-routing.html app.get("/", function (request, response) { response.sendFile(__dirname + '/views/index.html'); }); app.get("/search", function (request, response) { let query = request.query.query; console.log(request) // Search for artists using the query parameter on the request spotifyApi.searchArtists(query) .then(function(data) { console.log(data.body); // Return the JSON object from the API response.send(data.body); }, function(err) { console.log(err) }); spotifyApi.getArtistRelatedArtists(query) .then(function(data) { console.log(data.body); // Return the JSON object from the API response.send(data.body); }, function(err) { console.log(err) }); }); // listen for requests :) var listener = app.listen(process.env.PORT, function () { console.log('Your app is listening on port ' + listener.address().port); }); ----------------------------- $(function() { console.log('hello world :o'); $('form').submit(function(event) { event.preventDefault(); let query = $('input').val(); $.get('/search?' + $.param({query: query}), function(data) { $('#results').empty(); $('input[type="text"]').val(''); $('input').focus(); // Get the first ID from the JSON object let id = data.artists.items[0].id let relArtist = data.artists.items[0].relatedArtist $('#results').append($('<p>' + id + '</p>')); }); }); });```