I'm new to writing restful API's and read some documentation stuffs and I have some queries for which I don't get concrete solutions.
a) I can understand the fact that Restful guidelines define, for getting something from backend you have to hit with "GET" method (and) for posting something to backend you have to hit "POST" method.
b) Also, the fact that you can post with "GET" method and vice versa. HTTP methods are just methods and you can achieve anything with any methods.
As far you follow REST guidelines mentioned in point a), your design/code will look better. Indicating point b) that I'm aware of that too.
Questions
Are all Page-Request hit backend api with "GET" method only??? That is the way browser does default? Say for example, I'm hitting homepage of a website or any other page, does that trigger backend with only "GET" method?
If yes to question 1), Is there anyway I can hit a PAGE with "POST" method.
{Update : I just remember there is a way hitting a page with "POST" method using FORM post. Is that the only way now.?}
Please answer the above , question by question as I want to understand it clearly. Also, do correct me if I'm missing something.
Are all Page-Request hit backend api with "GET" method only??? That is the way browser does default? Say for example, I'm hitting homepage of a website or any other page, does that trigger backend with only "GET" method?
Yes. By default, if you type in address bar or click any link, then it will be a GET call.
If yes to question 1), Is there anyway I can hit a PAGE with "POST" method.
You can create a form and submit it like below ...
I know that, with Ajax calls you can hit backend API with any methods. Just an assertion that my understanding is correct.
Yes. You can define method type in Ajax call.