angular - Attempting to post authorization header but getting 404 whereas same post works in Postman -


i relatively new angular, not development.

i understand how http post supposed work. own function based on hero service tutorial post example.

the problem post works fine in postman. receive authorization token expected. however, when run angular app , see console, receive 404 not found receive if same url in postman.

{     "statuscode": 404,     "error": "not found" } 

below service , screenshots may helpful.

any ideas?

need additional information can provide?

thanks in advance.

import { injectable } '@angular/core'; import { headers, http } '@angular/http';  import 'rxjs/add/operator/topromise';  @injectable() export class theservice {   private baseurl = 'https://someserver.com';     private authurl = this.baseurl + '/auth';    constructor(private http: http) { }    getauth(apikey: string): promise<string> {     let headers = new headers();     headers.append('authorization', 'basic ' + apikey);      console.log('headers: ' + headers.get('authorization'));      return this.http       .post(this.authurl, '', {headers: headers})       .topromise()       .then(function(response) {         console.log('response:' + response.tostring());         return response.tostring();       })       .catch(this.handleerror);   }      private handleerror(error: any): promise<any> {       console.error('an error occurred', error);        return promise.reject(error.message || error);     }  } 

postman post request returning valid token

chrome console 404 error


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -