khulja-sim-sim 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +24 -0
  2. package/package.json +7 -0
package/index.js ADDED
@@ -0,0 +1,24 @@
1
+ // module.exports exports the function getContests as a promise and exposes it as a module.
2
+ // we can import an exported module by using require().
3
+ module.exports = async function getContests() {
4
+ const axios = require("axios"); // Importing the Axios module to make API requests
5
+ var result;
6
+
7
+ const username = "rajadwaita"; // Insert Your Username here
8
+ const api_key = "0571f18e68668af8bc8021e0af12f6ffb6281431"; //Insert API key here
9
+
10
+ await axios // Making a GET request using axios and requesting information from the API
11
+ .get(
12
+ "https://clist.by/api/v1/json/contest/?username=" + username + "&api_key=" + api_key + "&limit=20&end__gt=2020-09-19T00%3A00%3A00"
13
+ )
14
+ .then((response) => { // If the GET request is successful, this block is executed
15
+ return response; // The response of the API call is passed on to the next block
16
+ })
17
+ .then((contests) => { // In this block, we store the response data into a variable 'result'
18
+ result = contests.data.objects;
19
+ })
20
+ .catch((err) => {
21
+ console.log(err); // Error handler
22
+ });
23
+ return result; // The contest data is returned
24
+ };
package/package.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "khulja-sim-sim",
3
+ "version": "1.0.0",
4
+ "dependencies": {
5
+ "axios": "^1.1.3"
6
+ }
7
+ }