Separate endpoint for fetching person credits
This commit is contained in:
18
src/api.js
18
src/api.js
@@ -93,6 +93,23 @@ const getPerson = (id, credits = false) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches tmdb person credits by id.
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {object} Tmdb response
|
||||||
|
*/
|
||||||
|
const getPersonCredits = (id, credits = false) => {
|
||||||
|
const url = new URL("v2/person", SEASONED_URL);
|
||||||
|
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
||||||
|
|
||||||
|
return fetch(url.href)
|
||||||
|
.then(resp => resp.json())
|
||||||
|
.catch(error => {
|
||||||
|
console.error(`api error getting person: ${id}`);
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches tmdb list by name.
|
* Fetches tmdb list by name.
|
||||||
* @param {string} name List the fetch
|
* @param {string} name List the fetch
|
||||||
@@ -467,6 +484,7 @@ export {
|
|||||||
getMovie,
|
getMovie,
|
||||||
getShow,
|
getShow,
|
||||||
getPerson,
|
getPerson,
|
||||||
|
getPersonCredits,
|
||||||
getTmdbMovieListByName,
|
getTmdbMovieListByName,
|
||||||
searchTmdb,
|
searchTmdb,
|
||||||
getUserRequests,
|
getUserRequests,
|
||||||
|
|||||||
Reference in New Issue
Block a user