mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-03-11 11:55:38 +00:00
Requests are now posted with a body to endpoint /v2/requests
This commit is contained in:
22
src/api.js
22
src/api.js
@@ -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 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user