Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49238

Responded with a status of 401

$
0
0

@Nouf wrote:

I am getting this error when calling and I have to clue how to fix it

postData () {

   
    var headers = new HttpHeaders();
    headers = headers.set('Authorization','xxxxxxxxxxxxx');
    headers = headers.set('Content-Type','application/xxxxxxxxxx');
    headers = headers.set("Access-Control-Allow-Origin", "http://localhost:");
    headers = headers.set("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
    headers = headers.set("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Origin, Accept");


    // let requestOptions = {
    //   headers: new HttpHeaders()
    //  };
    // requestOptions.headers = headers;

    let body = {
      grant_type:'password',
      username:'user',
      password:'user'
    };

    console.log(qs.stringify(body))
    console.log(headers)

    this.http.post(apiUrl,qs.stringify(body), {headers : headers} )
    .subscribe(data=>{
      console.log(data.toString)
    });
    
    }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>