How to configure and make a https request from angular 2?
Couldn't find any resources on it.
Can please someone guide me here?
Thank you.
HttpRequest represents an outgoing request, including URL, method, headers, body, and other request configuration options. Instances should be assumed to be immutable. To modify a HttpRequest , the clone method should be used.
The HttpClientModule is a service module provided by Angular that allows us to perform HTTP requests and easily manipulate those requests and their responses. It is called a service module because it only instantiates services and does not export any components, directives or pipes.
then we are calling the get() method, which is returning an Observable. This observable returns an Object directly, so the HTTP library by default assumes that we have queried a JSON API and it internally parses the HTTP response body as JSON.
Just in case someone else is trying to do this
You should make the https calls just like the normal http calls but you have to ensure that your browser trust the certificate that is used by the backend APIs & that your browser can connect to this api.
Note:
It might give timeout error in YARC or REST clients so you should try a simple GET request directly in the browser (i.e: navigate to https get request)
For example, if we have this API
https://testDomain.com:7001/getCountries
Try to make a get request to this url by navigating to it in the browser, if you are testing locally or in UAT, your certificate might not be fully trusted in the browser automatically, so you have to tell chrome that you trust this website & go there (proceed to this website)
If you can successfully call this get request in the browser:
Then you can call the https apis just as you call normal http (with full correct URL having the https & the port number) as per the below resources:
1- Angular httpClient guide
2- You can also check out this excellent guide on making http calls in Angular 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With