Announcements

Help Wizard

Step 1

NEXT STEP

API calls dont work [JS | axios]

Solved!

API calls dont work [JS | axios]

Plan

Free

Country

Germany

Device

--

Operating System

Windows 10

 

My Question or Issue

Im trying to get the current Songs, but it always responses with eroro 404 not found.
I alr tried with using the API /current-playing but it responses the same error.

const axios = require('axios');
 
const clientId = 'clientID';
const token = 'BQC7gjB-m2VGqe1YV6g5,.._YeuJqYs__Mafmc';

axios.get(endpoint, {
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});
Reply

Accepted Solutions
Marked as solution

No problem.

Make sure you get an Acces Token using a Authorization Code flow (not Client Credentials).

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

View solution in original post

5 Replies

/v1/me/... btw.

You switched around me and v1 by mistake. It should be:

https://api.spotify.com/v1/me/player
XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Sorry, that I didnt answer for a long time. Thank you for your time!
I already saw that misstake, but the problem is still there. I can show you my current Code but the weird thing is, that a few other developer just "copy pasted" my Code and for them the Code works. And I just cant do many things like that. But a few things like 'GET ARTIST' are working. Maybe you know the problem.

const axios = require('axios');
require('dotenv').config();

const token = process.env.SPOTIFYTOKEN;


const mainFunction = async () => await axios.get(endpoint, {
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => {
  if (response.status === 204) {
    console.log('Response code  204');
  } else {
    console.log(response.data);
  }
})
.catch(error => {
  console.error(error);
});

mainFunction();
Marked as solution

No problem.

Make sure you get an Acces Token using a Authorization Code flow (not Client Credentials).

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Yeah, tysm haha
I just found it, If I'd just  check the reply I would be able to fix the Problem way faster.

Thank you very much for your help and stay healthy!

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random