Skip to content

Commit

Permalink
feat: add auth and top requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermeasper committed Sep 1, 2023
1 parent 17ca0cf commit bd4a5b5
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/services/marquinhosApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class MarquinhosApiService {
url: `${process.env.MARQUINHOS_API_URL}/api/scrobble/queue`,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.MARQUINHOS_API_TOKEN}`,
Authorization: `Bearer ${process.env.MARQUINHOS_API_KEY}`,
},
data: {
playbackData,
Expand All @@ -26,6 +26,44 @@ export class MarquinhosApiService {
const options = {
method: 'POST',
url: `${process.env.MARQUINHOS_API_URL}/api/scrobble/${id}`,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.MARQUINHOS_API_KEY}`,
},
};
try {
const { data } = await axios.request(options);
return data;
} catch (error) {
console.log(error);
return null;
}
}

async getTopArtists(id: string) {
const options = {
method: 'GET',
url: `${process.env.MARQUINHOS_API_URL}/api/user/top-artists/${id}`,
headers: {
Authorization: `Bearer ${process.env.MARQUINHOS_API_KEY}`,
},
};
try {
const { data } = await axios.request(options);
return data;
} catch (error) {
console.log(error);
return null;
}
}

async getTopAlbums(id: string) {
const options = {
method: 'GET',
url: `${process.env.MARQUINHOS_API_URL}/api/user/top-albums/${id}`,
headers: {
Authorization: `Bearer ${process.env.MARQUINHOS_API_KEY}`,
},
};
try {
const { data } = await axios.request(options);
Expand Down

0 comments on commit bd4a5b5

Please sign in to comment.