Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- POST: http://XX.XX.XX.XX:8081/login
- body {
- username
- password
- }
- import { Injectable } from '@angular/core';
- import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
- @Injectable()
- export class AuthService {
- readonly endpoint = 'http://XX.XX.XX.XX:8081/login';
- constructor(private readonly httpClient: HttpClient) { }
- post(userName: string, password: string) {
- console.log('AuthService.post has been executed!');
- const body = new HttpParams()
- .set('username', 'name')
- .set('password', 'pass');
- const headers = new HttpHeaders()
- .append('Content-Type', 'application/x-www-form-urlencoded');
- const options = {
- headers: headers
- };
- return this.httpClient.post(this.endpoint, body, options);
- }
- }
Add Comment
Please, Sign In to add comment