import { Component } from '@angular/core'; import { Http } from '@angular/http'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'app'; constructor(private http: Http) {} createUser() { const user = { name: 'John Doe', email: 'john.doe@example.com' } this.http.post('http://localhost:3000/users', user) .subscribe( data => console.log(data), error => console.log(error) ); } }In this example, we are using the Http post method to create a user by sending a POST request to the server with the user data in the request body. We are subscribing to the response and error streams to handle the response from the server. The package library for this code example is @angular/http.