mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-22 12:33:38 +08:00
29 lines
753 B
TypeScript
29 lines
753 B
TypeScript
/// <reference path="axios.d.ts" />
|
|
|
|
enum HttpMethod { GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH }
|
|
enum ResponseType { arraybuffer, blob, document, json, text }
|
|
|
|
interface Repository {
|
|
id: number;
|
|
name: string;
|
|
}
|
|
|
|
axios.get<Repository>("https://api.github.com/repos/mzabriskie/axios")
|
|
.then(r => console.log(r.config.method));
|
|
|
|
axios<Repository>({
|
|
url: "https://api.github.com/repos/mzabriskie/axios",
|
|
method: HttpMethod[HttpMethod.GET],
|
|
headers: {},
|
|
}).then(r => console.log("ID:" + r.data.id + " Name: " + r.data.name));
|
|
|
|
axios.post("http://example.com/", {}, {
|
|
transformRequest: (data: any) => data
|
|
});
|
|
|
|
axios.post("http://example.com/", {}, {
|
|
transformRequest: [
|
|
(data: any) => data
|
|
]
|
|
});
|