Tmdb search w/ adult and media type filters.
Adult is set to disable filtering adult material for search results. Media type checks if movie, show or person and appends type to url path for searches by type only. E.g. mediaType = 'show' -> api/v1/search/show?query=Friends.
This commit is contained in:
@@ -128,10 +128,15 @@ const getUserRequests = (page=1) => {
|
||||
* @param {number} [page=1]
|
||||
* @returns {object} Tmdb response
|
||||
*/
|
||||
const searchTmdb = (query, page=1) => {
|
||||
const searchTmdb = (query, page=1, adult=false, mediaType=null) => {
|
||||
const url = new URL('v2/search', SEASONED_URL)
|
||||
if (mediaType != null && ['movie', 'show', 'person'].includes(mediaType)) {
|
||||
url.pathname += `/${mediaType}`
|
||||
}
|
||||
|
||||
url.searchParams.append('query', query)
|
||||
url.searchParams.append('page', page)
|
||||
url.searchParams.append('adult', adult)
|
||||
|
||||
const headers = { authorization: localStorage.getItem('token') }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user