POST /add-artist
Adds a new artist to the data.json file.
Example URL
http://127.0.0.1:8080/add-artist
JSON body parameters
ArtistName
string
The artist's name.
Quote
string
A quote from one of the artist's songs.
CoverImage
string
Image address of an image of the artist found on the web. (NB : Ideally a Square Image, Spotify ones are perfect.)
SpotifyUrl **
string
SpotifyUrl link to one of the artist's playlist.
Card3A
array
The albums of our artist. (NB : Each album is separated by a Comma)
Card4
array
My top songs for that artist. (NB : Each song is separated by a Comma)
Card1
string
Content for a brief description on who that artist is.
Card2
string
Content for specified artist's rising to popularity explained.
** - To find the suitable Spotify Url for a playlist, follow the below steps :
Locate a playlist for your artist on Spotify, click into the Playlist and click the 3 dots.
At the bottom, you should see a share tab.
Hover over that and press embed playlist.
Once you are in embed playlist, click show code and an iframe code should pop up.
Extract the src part of the iframe (Without the quotation marks) and that is the Url to be inputted into the form.
Example Code
newartistform.addEventListener('submit', async (event) => {
event.preventDefault();
// Formatting the data to be sent to the server-side
const formData = new FormData(newartistform);
const formObject = Object.fromEntries(Array.from(formData.entries()));
const jsonData = JSON.stringify(formObject);
try {
const response = await fetch('http://127.0.0.1:8080/add-artist', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: jsonData
});
if (!response.ok) {
const errorD = await response.json();
throw new Error('Response Status: ' + response.status + ', Reason: ' + errorD.error);
}
} catch (error) {
alert(error);
}
});
Example Response
{
"ArtistName": "Your Artist",
"Quote": "Quote text",
"CoverImage": "http://example.com/image.jpg",
"SpotifyUrl": "http://spotify.com/artist/YourArtist",
"Card3A": ["item1", "item2", "item3"],
"Card4": ["item1", "item2", "item3"],
"Card1": "Card1 text",
"Card2": "Card2 text"
}
Response Code
200 OK: The artist was successfully added. The response body will contain the artist that was added.
400 Bad Request : The artist is already in the database and an error message will be sent.
Response Field
ArtistName
string
The artist's name.
Quote
string
A quote from one of the artist's songs.
CoverImage
string
Image address of the artist.
SpotifyUrl
string
SpotifyUrl link to one of the artist's playlist.
Card3A
array
The albums of our artist.
Card4
array
My top songs for that artist.
Card1
string
Content for a brief description on who that artist is.
Card2
string
Content for specified artist's rising to popularity explained.
Last updated