title: Getting 401 (Unauthorized) while post data Angular?
body: <p>My data is not posting in postman api 
  it gives the error:</p>
  
  <blockquote>
    <p>dradiobeats.x10host.com/api/areas:1 POST <a href="http://dradiobeats.x10host.com/api/areas" rel="nofollow noreferrer">http://dradiobeats.x10host.com/api/areas</a> 401 (Unauthorized)
    core.js:4002 ERROR HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: "Unauthorized", url: "<a href="http://dradiobeats.x10host.com/api/areas" rel="nofollow noreferrer">http://dradiobeats.x10host.com/api/areas</a>", ok: false, …}</p>
  </blockquote>
  
  <p>My app.component.ts</p>
  
  <pre><code>    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 =&gt; {
              console.log(responseData);
            });
        }
  </code></pre>
  
  <p>How can I resolve this error?</p>