Requests are now posted with a body to endpoint /v2/requests

This commit is contained in:
2019-06-28 22:30:37 +02:00
parent 0139d0b0da
commit 7e926bb37f
2 changed files with 19 additions and 7 deletions

View File

@@ -127,14 +127,26 @@ const addMagnet = (magnet, name, tmdb_id) => {
* @returns {object} Success/Failure response
*/
const request = (id, type, authorization_token=undefined) => {
const url = new URL('v1/plex/request', SEASONED_URL)
url.pathname = path.join(url.pathname, id.toString())
url.searchParams.append('type', type)
const url = new URL('v2/request', SEASONED_URL)
// url.pathname = path.join(url.pathname, id.toString())
// url.searchParams.append('type', type)
const headers = authorization_token ? { authorization: authorization_token } : {}
const headers = {
'Authorization': authorization_token,
'Content-Type': 'application/json'
}
const body = {
id: id,
type: type
}
return axios.post(url.href, { headers: headers })
.catch(error => { console.error(`api error requesting: ${id}, type: ${type}`); throw error })
return fetch(url.href, {
method: 'POST',
headers: headers,
body: JSON.stringify(body)
})
.then(resp => resp.json())
.catch(error => { console.error(`api error requesting: ${id}, type: ${type}`); throw error })
}
/**