Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

angular http

	constructor(private http: HttpClient) { }

	//GET ALL
	GetAll(): Observable<any> {
		return this.http.get(this.baseUrl + "/all");
	}
    
    //GET SINGLE
    GetSingle(id: any): Observable<any> {
		return this.http.get(this.baseUrl + "/single/" + id);
	}
    
    //PUT
    Update(obj: Object) {
		const data = JSON.stringify(obj);
		return this.http.put(this.baseUrl, data, {
			headers: new HttpHeaders({
				"Content-Type": "application/json",
			}),
		});
	}

    //POST
	Create(obj: Object) {
		const data = JSON.stringify(obj);
		return this.http.post(this.baseUrl, data, {
			headers: new HttpHeaders({
				"Content-Type": "application/json",
			}),
		});
	}
    //DELETE
	Delete(obj: Object) {
		const data = JSON.stringify(obj);
		return this.http.delete(this.baseUrl + "/delete", data, {
			headers: new HttpHeaders({
				"Content-Type": "application/json",
			}),
		});
	}
Comment

http get angular

ngOnInit() {
    this.http.get<any>('https://api.npms.io/v2/search?q=scope:angular').subscribe(data => {
        this.totalAngularPackages = data.total;
    })        
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: states on the west coast 
Typescript :: ts class 
Typescript :: check in Recat if an url is of image or video 
Typescript :: angular modal dismisss 
Typescript :: angular jasmine mock http request 
Typescript :: function to find the unique elements from two arrays 
Typescript :: sheets column number to letter 
Typescript :: declare jquery in typescript 
Typescript :: an apparmor policy prevents this sender from sending this message to this recipient 
Typescript :: react typescript scss 
Typescript :: mocha test typescript 
Typescript :: verify if room exists in socket.io 
Typescript :: java write arraylist of objects to file 
Typescript :: typescript with babel 
Typescript :: typescript object to array 
Typescript :: typescript check type of variable 
Typescript :: bullets in latex with header 
Typescript :: amcharts angular universal 
Typescript :: Catch clause variable cannot have a type annotation. 
Typescript :: ionic cannot be loaded because running scripts is disabled on this system. vscode 
Typescript :: NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct the issues below and execute "vagrant reload": 
Typescript :: create mock promise angular 
Typescript :: fgets input from user 
Typescript :: mongodb update all items in array 
Typescript :: angle between two vectors 
Typescript :: type script array 
Typescript :: web.contents timeout 
Typescript :: Ignoring ffi-1.15.3 because its extensions are not built 
Typescript :: View and navigate your assignments (teacher) code for asp.net 
Typescript :: tar: refusing to read archive contents from terminal (missing -f option?) tar: error is not recoverable: exiting now 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =