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,13 +127,25 @@ const addMagnet = (magnet, name, tmdb_id) => {
* @returns {object} Success/Failure response * @returns {object} Success/Failure response
*/ */
const request = (id, type, authorization_token=undefined) => { const request = (id, type, authorization_token=undefined) => {
const url = new URL('v1/plex/request', SEASONED_URL) const url = new URL('v2/request', SEASONED_URL)
url.pathname = path.join(url.pathname, id.toString()) // url.pathname = path.join(url.pathname, id.toString())
url.searchParams.append('type', type) // 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 }) 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 }) .catch(error => { console.error(`api error requesting: ${id}, type: ${type}`); throw error })
} }

View File

@@ -174,7 +174,7 @@ export default {
sendRequest(){ sendRequest(){
request(this.id, this.type, storage.token) request(this.id, this.type, storage.token)
.then(resp => { .then(resp => {
if (resp.data.success) { if (resp.success) {
this.requested = true this.requested = true
} }
}) })