Last active
July 18, 2024 00:19
-
-
Save adamgins/ba4f4550d80ef5375cc13f4a67f2252a to your computer and use it in GitHub Desktop.
Batch Create with API - no wait/throttle
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
import axios from "axios"; | |
const N = 5; // Number of times to repeat the request | |
let data = JSON.stringify({ | |
userEmail: "adam.ginsburg@buzzy.buzz", | |
appPrompt: | |
"Create an app for the company 'Treuhand A online' The company has the following description: 'A finance consulting company that helps customers do their accountings and optimizing taxes' The app is used in the following situation or is intended to solve the following problem: 'It always takes a lot of time to setup the account numbers and descriptions for new clients, even though they are very similar for everyone.' This is the idea of how the app should look: 'A finance accounting software that lets the owner manage the accounting for it's clients.' call the app testfin2", | |
}); | |
let config = { | |
method: "post", | |
maxBodyLength: Infinity, | |
url: "https://prototype.riwers.io/api/createappwithprompt", | |
headers: { | |
"X-Auth-Token": `${process.env.AUTHTOKEN}`, | |
"X-User-Id": ``, | |
"Content-Type": "application/json", | |
"x-api-key": `${process.env.APIKEY}`, | |
}, | |
data: data, | |
}; | |
async function makeRequests(n) { | |
for (let i = 0; i < n; i++) { | |
try { | |
const response = await axios.request(config); | |
console.log(`Response ${i + 1}:`, JSON.stringify(response.data)); | |
} catch (error) { | |
console.error(`Error ${i + 1}:`, error); | |
} | |
} | |
} | |
// Execute the function | |
makeRequests(N); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment