| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
HTTP client based on observables.
Compatible with both Javascript and Typescript.
import { http } from '@d3byte/rxjs-http';
const configuration = {
baseUrl: 'http://localhost:8080',
};
const httpClient = http(configuration);
httpClient
.post(
'login',
{ username: 'user', password: 'pass' },
{ MyCustomHeader: 'Value' },
)
.subscribe(user => {
// Do something with data
});All methods you would probably need are available in the package. You can use all of those:
The package supports configuring clients and keeping multiple instances of clients at the same time.
To configure a client, you have to pass a configuration object to http function.
This interface represents objects for configuring HTTP Client.
interface ConfigurationInterface {
jwt?: string;
baseUrl?: string;
defaultHeaders?: ObjectInterface;
}Properties:
A simple representation of object with dynamic keys and values. It suits for any object you would ever pass.
httpClient
.get(
'user',
{ MyCustomHeader: 'Value' },
)
.subscribe(user => {
// Do something with data
});httpClient
.post(
'login',
{ username: 'user', password: 'pass' },
{ MyCustomHeader: 'Value' },
)
.subscribe(user => {
// Do something with data
});httpClient
.put(
'books',
{ title: 'Fav Book' },
{ MyCustomHeader: 'Value' },
)
.subscribe(data => {
// Do something with data
});httpClient
.patch(
'books',
{ title: 'Fav Book' },
{ MyCustomHeader: 'Value' },
)
.subscribe(data => {
// Do something with data
});httpClient
.delete(
'books',
{ title: 'Fav Book' },
{ MyCustomHeader: 'Value' },
)
.subscribe(data => {
// Do something with data
});| Back | FazBrowse Home | New Git URL |