Request API
request is one of the most popular module on npm, it has been downloaded for 20~30 million time per day.
Just like Ajax methods of jQuery used in Front-end development and AFNetworking in iOS development, request is widely used in Node.js applications for requesting APIs.
Youdao dic
Youdao dic provides a Open platform for developers to register and apply for API services.
The most common way to request API is quite simple, we could just add parameters in the URL and request the API with GET method:
Next, we can have a try to call the API using request, we are going to get the Chinese meaning of the word ‘test’:
Assuming the codes above has been saved as a JavaScirpt file named , we could run it using node request-test.js
and get the following result: