3.0.2 • Published 7 months ago

ng-rest-http v3.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 months ago

ng-rest-http

http client module for Angular tested for angular6

Installation

npm install ng-rest-http

How to use

app.module.ts

import { RestHttpClientModule } from 'ng-rest-http'
@NgModule({
	imports: [ RestHttpClientModule ]
})

app.component.ts

import { RestHttpClient } from 'ng-rest-http'

export class AComponent{
	constructor(protected http:RestHttpClient){}

	const api_url = 'http://sample.domain.com/api/what';
	const params = {arg1: 'arg'.....};
	const headers = {
		'Access-Control-Allow-Origin': '*',
		'Content-Type': 'application/json',
		'Access-Control-Allow-Methods': 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
		'Access-Control-Allow-Headers': '*'
	};

	private get_sample(){
		this.http.get({url: api_url, params, headers}).then((res) => {
			console.log(res)
			// HttpResponse {body, headers: {...}, ok, status, statusText, type, url}
		});
	}

	private post_sample(){
		this.http.post({url: api_url, params, headers}).then((res) => {
			console.log(res)
			// HttpResponse {body, headers: {...}, ok, status, statusText, type, url}
		});
	}

	private filedownload_sample(){
		this.http.filedownload({url: api_url, params, headers}).then((blob) => {
			console.log(blob)
			// this.file.writeFile(this.localDirectory, link.icon, blob, {replace: true})
		});
	}
}

create user service for convenience

3.0.2

7 months ago

3.0.1

10 months ago

3.0.0

4 years ago

2.2.1

5 years ago

2.1.0

5 years ago

2.0.2

6 years ago

2.0.1

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago