Skip to content

Instantly share code, notes, and snippets.

@jonvuri
Created June 15, 2016 14:08
Show Gist options
  • Save jonvuri/ab82c80242e0eef38fc9a325399c1943 to your computer and use it in GitHub Desktop.
Save jonvuri/ab82c80242e0eef38fc9a325399c1943 to your computer and use it in GitHub Desktop.
[ignore]
.*/node_modules/babel.*
.*/node_modules/fbjs/.*
.*/node_modules/config-chain/.*
.*/node_modules/npmconf/.*
[include]
node_modules/
[libs]
flow-typed/npm/axios_v0.11.x.js
interfaces/
node_modules/iflow-react-redux/index.js.flow
node_modules/iflow-react-router/index.js.flow
node_modules/iflow-react-router-redux/index.js.flow
node_modules/iflow-redux-thunk/index.js.flow
[options]
module.name_mapper='.+\.css$' -> 'CSSModule'
module.name_mapper='^/\(.*\)$' -> '<PROJECT_ROOT>/src/\1'
module.system=haste
import axios from 'axios'
const axiosInstance = axios.create({
baseURL: '/elastic'
})
export default axiosInstance
// flow-typed signature: 9edc07d85cbbd18952917e0922efb3a1
// flow-typed version: 5e1c1576ae/axios_v0.11.x/flow_>=v0.23.x
declare module 'axios' {
declare interface AxiosXHRConfigBase<T> {
headers?: Object;
maxContentLength?: number;
params?: Object;
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
transformReponse?: <U>(data: T) => U;
transformRequest?: <U>(data: T) => U|Array<<U>(data: T) => U>;
validateStatus?: ?(status: number) => bool,
withCredentials?: boolean;
xsrfCookieName?: string;
xsrfHeaderName?: string;
}
declare interface AxiosXHRConfig<T> extends AxiosXHRConfigBase<T> {
data?: T;
method?: string;
url: string;
}
declare class AxiosXHR<T> {
config: AxiosXHRConfig<T>;
data: T;
headers: Object;
status: number;
statusText: string,
request: mixed, //this is the request object, not really typed currently.
}
declare class AxiosInterceptorIdent extends String {}
declare class AxiosRequestInterceptor<T> {
use(
successHandler: ?(response: AxiosXHRConfig<T>) => Promise<AxiosXHRConfig> | AxiosXHRConfig,
errorHandler: ?(error: mixed) => mixed,
): AxiosInterceptorIdent;
eject(ident: AxiosInterceptorIdent): void;
}
declare class AxiosResponseInterceptor<T> {
use(
successHandler: ?(response: AxiosXHR<T>) => mixed,
errorHandler: ?(error: mixed) => mixed,
): AxiosInterceptorIdent;
eject(ident: AxiosInterceptorIdent): void;
}
declare class Axios {
constructor<T>(config: AxiosXHRConfigBase<T>): Promise<T>;
<T>(config: AxiosXHRConfigBase<T>): Promise<T>;
get: <T>(url: string, config?: AxiosXHRConfigBase<T>) => Promise<T>;
delete: <T>(url: string, config?: AxiosXHRConfigBase<T>) => Promise<T>;
head: <T>(url: string, config?: AxiosXHRConfigBase<T>) => Promise<T>;
post: <T>(url: string, data?: mixed, config?: AxiosXHRConfigBase<T>) => Promise<T>;
put: <T>(url: string, data?: mixed, config?: AxiosXHRConfigBase<T>) => Promise<T>;
interceptors: {
request: AxiosRequestInterceptor<mixed>,
response: AxiosResponseInterceptor<mixed>,
},
}
declare var exports: Axios;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment