Created
December 23, 2020 15:03
-
-
Save nsrau/2efb8bd98812c4fb4eb6638b4b1dca97 to your computer and use it in GitHub Desktop.
create a dynamic data to test
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, { Method } from 'axios'; | |
(async (forNumber) => { | |
const arr = Array(10 * forNumber).fill(null).map((n, i) => i) | |
for (const i of arr) { | |
try { | |
const PreviousMessages = arr.slice(0, i + 1).fill(null).map((n, index) => { | |
return { | |
msg: index, | |
createdOn: new Date().toISOString() | |
} | |
}); | |
const config = { | |
method: 'POST' as Method, | |
url: 'endpoint', | |
data: { | |
"msg": i, | |
PreviousMessages | |
} | |
}; | |
const req = async () => { | |
return await axios(config) | |
} | |
const res = await req() | |
console.log(res.data) | |
} catch (e) { | |
console.error(e) | |
} | |
} | |
})(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment