JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API
https://jmperezperez.com/spotify-web-api-js/
MIT License
1.86k stars 260 forks source link

getGeneric() producing an error: JSON Parse error: Unrecognized token '<' #199

Closed lucasbeatdapp closed 2 years ago

lucasbeatdapp commented 3 years ago

Describe the bug I'm wanting to use the getGeneric() api call to be able to past a spotify url into an input with React native in order to get the content from that url but I receive an error

JSON Parse error: Unrecognized token '<'

To Reproduce Steps to reproduce the behavior:

  1. Run code '...'

searchTerm will be something like this TaylorSwift. A url copied directly from spotify's share.

Screen Shot 2021-05-20 at 4 30 02 PM
const fetchInfo = async (searchTerm) => {
    const searchResults = await spotifyApi.getGeneric(searchTerm);
    console.log("searchResults", searchResults);
}
  1. See error Screen Shot 2021-05-20 at 4 28 00 PM

Expected behavior For this request, I'd expect to see results returned for the link provided. Maybe an object that holds all the data for the request whether it's an artist, album, track, or playlist

Screenshots If applicable, add screenshots to help explain your problem.

Screen Shot 2021-05-20 at 4 32 16 PM

Screen Shot 2021-05-20 at 4 33 53 PM

Desktop (please complete the following information):

Additional context the app is expo managed

package version: spotify-web-api-js": "^1.5.1"

JMPerez commented 2 years ago

@lucasbeatdapp you probably want to use the searchfunction instead of the internal getGeneric.