@fruitsjs/http
Version:
FruitsJS Generic Http Module
39 lines (27 loc) • 774 B
Markdown
Generic HTTP client that is used as a network provider for @fruitsjs/core.
`@fruitsjs/http` can be used with NodeJS or Web.
Install using [npm](https://www.npmjs.org/):
```
npm install @fruitsjs/http
```
or using [yarn](https://yarnpkg.com/):
``` yarn
yarn add @fruitsjs/http
```
```js
import {HttpImpl} from '@fruitsjs/http'
async function getTodos() {
try{
const client = new HttpClientFactory.createHttpClient('https://jsonplaceholder.typicode.com/');
const result = await client.get('/todos/1')
console.log(result)
}
catch(httpError){
console.error(httpError.message)
}
}
```