I have developed GET route handler for some endpoint (Eg: localhost:4200/app/all) .When i tried this in browser url, it gives me the intended data.But if i have any POST request endpoints, it does not work.Obviously i have no idea how request body is taken here.I have concluded that the browser works only for get request.Is this right,does the browser always make the GET request ?? Or we can also send POST requests ??
Asked
Active
Viewed 1,233 times
3 Answers
3
Browsers typically can only send GET requests (when you enter a URL and press enter). To make POST requests to an endpoint.
To make post requests, there are a couple of ways:

Yash Shah
- 131
- 5
-
thanks, yes i am aware of POSTMAN , but i am trying to understand how http requests works in browser by default – Sathya Narayanan GVK Apr 07 '20 at 08:36
3
When you type a URL in the address bar of your browser, it performs a GET request to retrive the content at the specified end-point.
If you want it to perform a POST request you can either create a form with method POST or use a JavaScript function (e.g. fetch) with the necessary arguments.
For more information:

Carlo Dell'Acqua
- 46
- 2
- 3
1
The browser per default makes GET requests since that is what it is doing, it is getting stuff. POST-requests can be made from the browser using javascript (ie XHR/Fetch) or when using html forms with the method-attribute.
<form action="/form-endpoint" method="POST">
<input type="text" id="username" name="username">
</form>

Karl-Johan Sjögren
- 16,544
- 7
- 59
- 68