Please log in to watch this conference skillscast.
A very common situation in web development: you need to make multiple requests, often with some conditions and logic between calls, to get the required result.
It can be achieved in three ways:
Sending multiple requests to the server and implementing all the processing logic in the client. The advantage of this approach is that the server remains unchanged and the client can easily change the logic and flow of requests. The disadvantage is the latency and the traffic - each request should travel via the network.
Implementing additional methods/endpoints/parameters in the server. The advantage of this approach is that the client has to make only one request. The disadvantage is that it requires changing the server (= coding + testing + documenting + deploying + monitoring + supporting...). When it is possible, it inevitably leads to the growing complexity of the remote system as more and more specialised methods/APIs are added to it.
Implement batch endpoints, e.g. using JSON RPC standard. While they allows to execute multiple calls in a single HTTP request, it doesn’t allow to implement any logic between the calls.
JSONScript is a simple tool that allows to create “a batch endpoint on steroids” - server-side scripted execution of existing endpoints and services.
It is currently implemented in express middleware that allows to add JSONScript batch endpoint in a single line of code.
YOU MAY ALSO LIKE:
Batch execution of existing endpoints and services with JSONScript
Evgeny is the Head of Development at MailOnline, where he leads the team of software engineers who develop and maintain in-house, cutting-edge news authoring and publishing web/mobile platform used by 800 journalists in London, New York, Los Angeles and Sydney to create 1000+ articles every day. The website http://www.dailymail.co.uk is visited by 230 million unique visitors every month.