-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
npm i | ||
provide your API_Key in prompt.js | ||
node prompt.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "aiprompty", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "prompt.js", | ||
"type":"module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Michał Furmaniak", | ||
"license": "ISC", | ||
"dependencies": { | ||
"node-fetch": "^3.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
const APIKey = ''; | ||
|
||
// Function to make a request with a delay | ||
async function makeRequestWithDelay(url, options, delay) { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(async () => { | ||
try { | ||
const response = await fetch(url, options); | ||
const data = await response.json(); | ||
resolve(data); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}, delay); | ||
}); | ||
} | ||
|
||
// First curl command | ||
fetch('https://tasks.aidevs.pl/token/helloapi', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({apikey: APIKey}) | ||
}) | ||
.then(async (response) => { | ||
const data = await response.json(); | ||
console.log(data); | ||
const token = data.token; | ||
const url = `https://tasks.aidevs.pl/task/${token}`; | ||
console.log(token); | ||
console.log(url); | ||
|
||
// Second curl command with a delay of 2000 milliseconds (2 seconds) | ||
const response2 = await makeRequestWithDelay(url, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}, 10); | ||
const cookie = response2.cookie; | ||
// Third curl command with a delay of 2000 milliseconds (2 seconds) | ||
const response3 = await makeRequestWithDelay(`https://tasks.aidevs.pl/answer/${token}`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({answer: cookie}) | ||
}, 10); | ||
console.log(response3); | ||
}) | ||
.catch(error => console.error('Error:', error)); |