Implement some flow and cleanup API call for file manager
This commit is contained in:
parent
c3ef290145
commit
aee42df3ad
9 changed files with 186 additions and 118 deletions
25
resources/assets/scripts/api/http.js
Normal file
25
resources/assets/scripts/api/http.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
// @flow
|
||||
import axios from 'axios';
|
||||
import type { AxiosInstance } from 'axios';
|
||||
|
||||
// This token is set in the bootstrap.js file at the beginning of the request
|
||||
// and is carried through from there.
|
||||
// const token: string = '';
|
||||
|
||||
const http: AxiosInstance = axios.create({
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
});
|
||||
|
||||
// If we have a phpdebugbar instance registered at this point in time go
|
||||
// ahead and route the response data through to it so things show up.
|
||||
if (typeof window.phpdebugbar !== 'undefined') {
|
||||
http.interceptors.response.use(response => {
|
||||
window.phpdebugbar.ajaxHandler.handle(response.request);
|
||||
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
export default http;
|
Reference in a new issue