To handle a JSONP request, consider the following procedure we need to implement on the server side:
- Add one more case in our switch block that represents a JSONP request. To do so, consider the following code:
case '/.jsonp': break;
- Once we have our route case ready, the first thing to do is to implement the query parsing logic. In our case, we have already done this operation by using the `querystring.parse` method to parse the query object. This will get the callback details passed as a query parameter from the URL. Next, we need to create a JSONP response as shown in the preceding section. We need first to stringify the JSON response and then pad it into a JSONP callback received from our client:
case ...