InterviewSolution
| 1. |
Explain the term statelessness with respect to RESTful web Services. Write its advantages. |
|
Answer» Statelessness is basically a condition or restriction where RESTful web services are not allowed to keep a client state on the SERVER as per the REST architecture. Clients are responsible to pass their context to the server. To process the client’s request, the server then further stores this context.
Example: Simple GET Request using NodeJS We have the following sample data in users.json file. Implement our RESTful API listUsers using the following code in a server.js file. Now open a browser and go to http://127.0.0.1:8081/listUsers, we will get the following response: { "user1" : { "name" : "gourav", "password" : "password1", "profession" : "officer", "id": 1 }, "user2" : { "name" : "nikhil", "password" : "password2", "profession" : "teacher", "id": 2 }} |
|