Created
August 19, 2022 20:45
-
-
Save Vetrivel-VP/4ae1ddcc32a4e79ff0253485dce039ff to your computer and use it in GitHub Desktop.
Support Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
const baseURL = "http://localhost:4000/"; | |
export const validateUser = async (token) => { | |
try { | |
const res = await axios.get(`${baseURL}api/users/login`, { | |
headers: { | |
Authorization: "Bearer " + token, | |
}, | |
}); | |
return res.data; | |
} catch (error) {} | |
}; | |
export const getAllUsers = async () => { | |
try { | |
const res = await axios.get(`${baseURL}api/users/getUsers`); | |
return res.data; | |
} catch (error) { | |
return null; | |
} | |
}; | |
export const getAllArtists = async () => { | |
try { | |
const res = await axios.get(`${baseURL}api/artists/getAll`); | |
return res.data; | |
} catch (error) { | |
return null; | |
} | |
}; | |
export const getAllAlbumns = async () => { | |
try { | |
const res = await axios.get(`${baseURL}api/albums/getAll`); | |
return res.data; | |
} catch (error) { | |
return null; | |
} | |
}; | |
export const getAllSongs = async () => { | |
try { | |
const res = await axios.get(`${baseURL}api/songs/getAll`); | |
return res.data; | |
} catch (error) { | |
return null; | |
} | |
}; | |
export const changingUserRole = async (userId, role) => { | |
try { | |
const res = axios.put(`${baseURL}api/users/updateRole/${userId}`, { | |
data: { role: role }, | |
}); | |
return res; | |
} catch (error) { | |
return null; | |
} | |
}; | |
export const removeUser = async (userId) => { | |
try { | |
const res = axios.delete(`${baseURL}api/users/deleteUser/${userId}`); | |
return res; | |
} catch (error) { | |
return null; | |
} | |
}; | |
export const saveNewSong = async (data) => { | |
try { | |
const res = axios.post(`${baseURL}api/songs/save`, { ...data }); | |
return (await res).data.savedSong; | |
} catch (error) { | |
return null; | |
} | |
}; | |
Support Functions | |
export const filters = [ | |
{ id: 2, name: "Jasp", value: "jasp" }, | |
{ id: 3, name: "Rock", value: "rock" }, | |
{ id: 4, name: "Melody", value: "melody" }, | |
{ id: 5, name: "Karoke", value: "karoke" }, | |
]; | |
export const filterByLanguage = [ | |
{ id: 1, name: "Tamil", value: "tamil" }, | |
{ id: 2, name: "English", value: "english" }, | |
{ id: 3, name: "Malayalam", value: "malayalam" }, | |
{ id: 4, name: "Telungu", value: "Telungu" }, | |
{ id: 5, name: "Hindi", value: "hindi" }, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment