- Notifications
You must be signed in to change notification settings - Fork5
🚀🚀make ts project easy to requset transform model
License
NotificationsYou must be signed in to change notification settings
RainManGO/axios-mapper
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
axios-mapper can make ts project easy to transform model 🚀🚀 and Prevent duplicate network requests
npm install axios-mapper
or
yarn add axios-mapper
- axios easy to request and return data auto transform model
- prevent duplicate network requests
1、base setting
importHttpClient,{HttpClientConfig}from"../src/index";constconfig:HttpClientConfig={baseURL:'http://www.httpbin.org',headers:{token:'your token'}}consthttps=newHttpClient(config)exportdefaulthttps
2 、use tool get model
vscode extension :json2tsweb:http://json2ts.com
// {// "slideshow": {// "author": "Yours Truly",// "date": "date of publication",// "slides": [// {// "title": "Wake up to WonderWidgets!",// "type": "all"// },// {// "items": [// "Why <em>WonderWidgets</em> are great",// "Who <em>buys</em> WonderWidgets"// ],// "title": "Overview",// "type": "all"// }// ],// "title": "Sample Slide Show"// }// }exportinterfaceSlide{title:string;type:string;}exportinterfaceSlideshow{author:string;date:string;slides:Slide[];title:string;}exportinterfaceRootObject{slideshow:Slideshow;}
3、request
importhttpsfrom"./http";import{RootObject}from"./model";https.request<RootObject>('/json').then((res)=>{console.log(res?.slideshow);})
- axios
- qs
usetsdx to publish
axios-mapper: Axios is open-sourced software licensed under theMIT license.
About
🚀🚀make ts project easy to requset transform model
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published