Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🚀🚀make ts project easy to requset transform model

License

NotificationsYou must be signed in to change notification settings

RainManGO/axios-mapper

Repository files navigation

Language:English |中文简体

axios mapper

npmnpmnpmnpmLicense

axios-mapper can make ts project easy to transform model 🚀🚀 and Prevent duplicate network requests

Install

  npm install  axios-mapper

or

  yarn add axios-mapper

Features

  • axios easy to request and return data auto transform model
  • prevent duplicate network requests

Usage

 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);})

Dependency

  • axios
  • qs

Scripts

usetsdx to publish

License

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

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp