Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skunight/http-client-decorator
web http client decorator
https://github.com/skunight/http-client-decorator
Last synced: 10 days ago
JSON representation
web http client decorator
- Host: GitHub
- URL: https://github.com/skunight/http-client-decorator
- Owner: skunight
- License: mit
- Created: 2018-12-25T03:58:30.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-26T02:49:56.000Z (almost 6 years ago)
- Last Synced: 2024-10-14T06:52:06.647Z (about 1 month ago)
- Language: TypeScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Http Client Decorator
web http client decorator
### Installation
**Yarn**
```bash
yarn add http-client-decorator
```**NPM**
```bash
npm install http-client-decorator --save
```### Getting Started
Http client is use [Axios](https://github.com/axios/axios)```typescript
@Http(options) //options is Axios.create options
class Test {
@Get('url',{data},{config}) //config is instance.request config
method1(@Res res?) {
}
@Post('url',{data},{config})
method2(@Res res?) {
}
@Fetch(RequestMethod.PUT,'url',{data},{config})
method3(@Res res?) {
}
}
```
RequestMethod is a enum
```typescript
enum RequestMethod {
GET = 'GET',
POST = 'POST',
HEAD = 'HEAD',
PUT = 'PUT',
DELETE = 'DELETE',
OPTIONS = 'OPTIONS',
PATCH = 'PATCH',
}
```That's it!