Handle broken links better
This commit is contained in:
parent
b5f99b217a
commit
3abe8f1a79
4 changed files with 93 additions and 70 deletions
|
@ -44,6 +44,12 @@ export async function lookupId(id, type) {
|
|||
|
||||
data = data.body[`${type}s`][0];
|
||||
|
||||
if(!data) {
|
||||
const error = new Error('Not Found');
|
||||
error.status = 404;
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
const artist = data.artists[0];
|
||||
|
||||
if (type === 'album') {
|
||||
|
@ -82,7 +88,9 @@ export async function lookupId(id, type) {
|
|||
},
|
||||
};
|
||||
}
|
||||
return { service: 'spotify' };
|
||||
const error = new Error('Not Found');
|
||||
error.status = 404;
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
export async function search(data, original = {}) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue