mirror of
https://github.com/ansible/awx.git
synced 2026-01-28 23:04:41 -03:30
Peel axios instantiation out into it's own file so that it can be used in the RelatedAPI model
This commit is contained in:
parent
4b51c71220
commit
6889128571
13
awx/ui_next/src/api/AxiosHTTP.js
Normal file
13
awx/ui_next/src/api/AxiosHTTP.js
Normal file
@ -0,0 +1,13 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import { encodeQueryString } from '../util/qs';
|
||||
|
||||
const AxiosHTTP = axios.create({
|
||||
xsrfCookieName: 'csrftoken',
|
||||
xsrfHeaderName: 'X-CSRFToken',
|
||||
paramsSerializer(params) {
|
||||
return encodeQueryString(params);
|
||||
},
|
||||
});
|
||||
|
||||
export default AxiosHTTP;
|
||||
@ -1,17 +1,7 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import { encodeQueryString } from '../util/qs';
|
||||
|
||||
const defaultHttp = axios.create({
|
||||
xsrfCookieName: 'csrftoken',
|
||||
xsrfHeaderName: 'X-CSRFToken',
|
||||
paramsSerializer(params) {
|
||||
return encodeQueryString(params);
|
||||
},
|
||||
});
|
||||
import AxiosHTTP from './AxiosHTTP';
|
||||
|
||||
class Base {
|
||||
constructor(http = defaultHttp, baseURL) {
|
||||
constructor(http = AxiosHTTP, baseURL) {
|
||||
this.http = http;
|
||||
this.baseUrl = baseURL;
|
||||
}
|
||||
|
||||
31
awx/ui_next/src/api/models/Related.js
Normal file
31
awx/ui_next/src/api/models/Related.js
Normal file
@ -0,0 +1,31 @@
|
||||
import AxiosHTTP from '../AxiosHTTP';
|
||||
|
||||
class Related {
|
||||
constructor(http = AxiosHTTP) {
|
||||
this.http = http;
|
||||
}
|
||||
|
||||
delete(relatedEndpoint) {
|
||||
return this.http.delete(relatedEndpoint);
|
||||
}
|
||||
|
||||
get(relatedEndpoint, params) {
|
||||
return this.http.get(relatedEndpoint, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
patch(relatedEndpoint, data) {
|
||||
return this.http.patch(relatedEndpoint, data);
|
||||
}
|
||||
|
||||
post(relatedEndpoint, data) {
|
||||
return this.http.post(relatedEndpoint, data);
|
||||
}
|
||||
|
||||
put(relatedEndpoint, data) {
|
||||
return this.http.put(relatedEndpoint, data);
|
||||
}
|
||||
}
|
||||
|
||||
export default Related;
|
||||
Loading…
x
Reference in New Issue
Block a user