tnort's avatar
Level 4

Spotify api consumed by React app through Laravel api

Hi all,

I have a more general question but I highly appreciated any help. I am building and React app that basically searches for albums by letting the user enter desired album title. As the user clicks the search button I would like to send a request from my React app to my Laravel API which should basically attach the Auth Token to the request and fetch the required data from Spotify API and then return it to the React app.

The problem is that I manage to get a token only if I run my backend alone following this documentation https://developer.spotify.com/documentation/general/guides/authorization/code-flow/. But, I cannot get my React app to request a token when is first time launched (useEffect), which is then stored by the server and appended by the server each time a request is made.

How would I approach solving this issue? Thank you!

0 likes
3 replies
WilliamBatsa's avatar

hy bro i want to make a downloader to download spotify songs and also an android app like this https:// spotifymod.com/spotify-downloader-apk/ can you create it?

KaylaRogers's avatar

Using the Spotify API in a React app through a Laravel API is a common approach to manage authentication and data requests securely. Laravel can handle server-side logic, including storing API credentials, managing access tokens, and making requests to Spotify, while React focuses on rendering the data and creating an interactive user interface. This separation keeps sensitive information secure on the backend, reduces the exposure of tokens, and allows the frontend to consume only the processed data, making the app more maintainable and scalable, and enabling each page to load Spotify content efficiently.

Please or to participate in this conversation.