- Need NodeJS installed on your machine
- Unix Based OS (Preferably Ubuntu or MacOS)
The solutions to the questions are stored in the folder q1, q2 , q3 and q4 respectively.
Install the collections modules first.
npm install collections --save
Open the terminal on your machine
-
In order to create an API_KEY, refer to this link in order to get a personal access token.
-
Create an environment variable using the API key gained from the last step.
export token=API_KEY
- Install the node-fetch module
npm install node-fetch
- Change your directory to q2 and run the file q2.js in the terminal like so.
cd q2
node q2.js
A prompt appears
Enter a query or press enter to use the default query provided:
Enter your search query to get started and wait for the results to appear. The default query is this
tetris&sort=stars&order=desc
This searches for the keyword "tetris" and sorts the results in descending order by the number of the stars on the repositories.
Refer to this documentation to learn how to do more complex searches.
To run the solution of the question using async-await, try this:
node q3_await.js 1999 2019 chemistry
The preferred order for the command line arguments are:
first_year last_year subject
To run the solution using promise,run the other file like this
node q3_promise.js 1977 2020 peace
To run the solution of the question using async-await, try this:
node q4_await.js
In order to run the solution using promise,run the other file like this
node q4_promise.js