My data is not posting in postman api it gives the error:
dradiobeats.x10host.com/api/areas:1 POST http://dradiobeats.x10host.com/api/areas 401 (Unauthorized) core.js:4002 ERROR HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: "Unauthorized", url: "http://dradiobeats.x10host.com/api/areas", ok: false, …}
My app.component.ts
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
loadedPosts = [];
constructor(private http: HttpClient) {}
ngOnInit() {
this.fetchPosts();
}
onCreatePost(postData: { id: number; content: string }) {
// Send Http request
this.http
.post(
'http://dradiobeats.x10host.com/api/areas',
postData
)
.subscribe(responseData => {
console.log(responseData);
});
}
How can I resolve this error?