|
@@ -25,6 +25,10 @@ module.exports = class RequestClient {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ get headers () {
|
|
|
|
+ return Object.assign({}, this.defaultHeaders, this.opts.serverHeaders || {})
|
|
|
|
+ }
|
|
|
|
+
|
|
onReceiveResponse (response) {
|
|
onReceiveResponse (response) {
|
|
const state = this.uppy.getState()
|
|
const state = this.uppy.getState()
|
|
const uppyServer = state.uppyServer || {}
|
|
const uppyServer = state.uppyServer || {}
|
|
@@ -51,7 +55,7 @@ module.exports = class RequestClient {
|
|
get (path) {
|
|
get (path) {
|
|
return fetch(this._getUrl(path), {
|
|
return fetch(this._getUrl(path), {
|
|
method: 'get',
|
|
method: 'get',
|
|
- headers: this.defaultHeaders
|
|
|
|
|
|
+ headers: this.headers
|
|
})
|
|
})
|
|
// @todo validate response status before calling json
|
|
// @todo validate response status before calling json
|
|
.then(this.onReceiveResponse)
|
|
.then(this.onReceiveResponse)
|
|
@@ -64,7 +68,7 @@ module.exports = class RequestClient {
|
|
post (path, data) {
|
|
post (path, data) {
|
|
return fetch(this._getUrl(path), {
|
|
return fetch(this._getUrl(path), {
|
|
method: 'post',
|
|
method: 'post',
|
|
- headers: this.defaultHeaders,
|
|
|
|
|
|
+ headers: this.headers,
|
|
body: JSON.stringify(data)
|
|
body: JSON.stringify(data)
|
|
})
|
|
})
|
|
.then(this.onReceiveResponse)
|
|
.then(this.onReceiveResponse)
|
|
@@ -82,11 +86,7 @@ module.exports = class RequestClient {
|
|
delete (path, data) {
|
|
delete (path, data) {
|
|
return fetch(`${this.hostname}/${path}`, {
|
|
return fetch(`${this.hostname}/${path}`, {
|
|
method: 'delete',
|
|
method: 'delete',
|
|
- credentials: 'include',
|
|
|
|
- headers: {
|
|
|
|
- 'Accept': 'application/json',
|
|
|
|
- 'Content-Type': 'application/json'
|
|
|
|
- },
|
|
|
|
|
|
+ headers: this.headers,
|
|
body: data ? JSON.stringify(data) : null
|
|
body: data ? JSON.stringify(data) : null
|
|
})
|
|
})
|
|
.then(this.onReceiveResponse)
|
|
.then(this.onReceiveResponse)
|