Search code examples
angularhttp-posthttprequest

how to pass api key along with the post request


I'm using angular and have post request, I got unauthorize error which turned out. I need to pass the api key as well, here is my post request:

SendToBackEnd(){         
    var x=new mymodel();
    x.settlementCurrency='EUR';
    x.customerReference='m455';
    x.paymentReference='65465465';
    this.http.post("address",x).subscribe(s=>{
    });
}

Could you please help me with that? no idea how I should pass the api key along with my request


Solution

  • Where is located address provide parameter for Auth to your end point

    var address = 'https://adressToEndpoint.com/?apiKey=key 
    
      SendToBackEnd(){         
            var x=new mymodel();
            x.settlementCurrency='EUR';
            x.customerReference='m455';
            x.paymentReference='65465465';
            this.http.post("address",x).subscribe(s=>{
            });
          }