mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
create @types/lifeomic__axios-fetch (#39227)
This commit is contained in:
committed by
Wesley Wigham
parent
1db2d563c0
commit
cdd7ff1a42
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for @lifeomic/axios-fetch 1.4
|
||||
// Project: https://github.com/lifeomic/axios-fetch
|
||||
// Definitions by: Jason Di Benedetto <https://github.com/jasondibenedetto>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Response, RequestInfo, RequestInit } from 'node-fetch';
|
||||
import { AxiosInstance, AxiosTransformer } from 'axios';
|
||||
|
||||
export function buildAxiosFetch(
|
||||
axios: AxiosInstance,
|
||||
transformer?: AxiosTransformer,
|
||||
): (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
||||
@@ -0,0 +1,18 @@
|
||||
import axios from 'axios';
|
||||
import { buildAxiosFetch } from '@lifeomic/axios-fetch';
|
||||
|
||||
const instance = axios.create();
|
||||
|
||||
const fetch = buildAxiosFetch(instance, config => {
|
||||
config.timeout = 1000;
|
||||
return config;
|
||||
});
|
||||
|
||||
fetch('https://jsonplaceholder.typicode.com/users', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then(response => {
|
||||
return response.json();
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@lifeomic/axios-fetch": [
|
||||
"lifeomic__axios-fetch"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lifeomic__axios-fetch-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user