Lines 6-11
class HttpClient {
Link Here
|
6 |
this._headers = options.headers || { |
6 |
this._headers = options.headers || { |
7 |
"Content-Type": "application/json;charset=utf-8", |
7 |
"Content-Type": "application/json;charset=utf-8", |
8 |
}; |
8 |
}; |
|
|
9 |
this.csrf_token = $('meta[name="csrf-token"]').attr("content"); |
9 |
} |
10 |
} |
10 |
|
11 |
|
11 |
async _fetchJSON( |
12 |
async _fetchJSON( |
Lines 83-91
class HttpClient {
Link Here
|
83 |
? params.body |
84 |
? params.body |
84 |
: JSON.stringify(params.body) |
85 |
: JSON.stringify(params.body) |
85 |
: undefined; |
86 |
: undefined; |
|
|
87 |
let csrf_token = { "CSRF-TOKEN": this.csrf_token }; |
88 |
let headers = { ...csrf_token, ...params.headers }; |
86 |
return this._fetchJSON( |
89 |
return this._fetchJSON( |
87 |
params.endpoint, |
90 |
params.endpoint, |
88 |
params.headers, |
91 |
headers, |
89 |
{ |
92 |
{ |
90 |
...params.options, |
93 |
...params.options, |
91 |
body, |
94 |
body, |
Lines 102-110
class HttpClient {
Link Here
|
102 |
? params.body |
105 |
? params.body |
103 |
: JSON.stringify(params.body) |
106 |
: JSON.stringify(params.body) |
104 |
: undefined; |
107 |
: undefined; |
|
|
108 |
let csrf_token = { "CSRF-TOKEN": this.csrf_token }; |
109 |
let headers = { ...csrf_token, ...params.headers }; |
105 |
return this._fetchJSON( |
110 |
return this._fetchJSON( |
106 |
params.endpoint, |
111 |
params.endpoint, |
107 |
params.headers, |
112 |
headers, |
108 |
{ |
113 |
{ |
109 |
...params.options, |
114 |
...params.options, |
110 |
body, |
115 |
body, |
Lines 116-124
class HttpClient {
Link Here
|
116 |
} |
121 |
} |
117 |
|
122 |
|
118 |
delete(params = {}) { |
123 |
delete(params = {}) { |
|
|
124 |
let csrf_token = { "CSRF-TOKEN": this.csrf_token }; |
125 |
let headers = { ...csrf_token, ...params.headers }; |
119 |
return this._fetchJSON( |
126 |
return this._fetchJSON( |
120 |
params.endpoint, |
127 |
params.endpoint, |
121 |
params.headers, |
128 |
headers, |
122 |
{ |
129 |
{ |
123 |
parseResponse: false, |
130 |
parseResponse: false, |
124 |
...params.options, |
131 |
...params.options, |
125 |
- |
|
|