0.1.0 • Published 8 months ago

mharj-http-client v0.1.0

Weekly downloads
4
License
LGPL-2.1-or-later
Repository
github
Last release
8 months ago

mharj-http-client

// initialize http client with 200ms delay on loading state change if progress is not supported (defaults 100ms)
const {fetch, addLoadingEventListener, addProgressEventListener} = HttpClient.getInstance({delay: 200});
addLoadingEventListener((isLoading: boolean) => {
	// do something for state boolean i.e. update redux state
});
addProgressEventListener((progress: IProgressPayload) => {
	// do something with download progress data {url: string; start?: Date; received?: number; size?: number; done: boolean}
});
export default fetch;

with logger (console, log4js)

// initialize http client
const {fetch} = HttpClient.getInstance({logger: console});
export default fetch;

track Response body readable stream (if body stream reading is supported)

const res = await fetch('https://google.com');
watchResponseProgress(res, (progress) => console.log(progress));
const data = await res.text();
0.1.0

8 months ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.11

2 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

5 years ago