Skip to content

Instantly share code, notes, and snippets.

@nsrau
Created December 23, 2020 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsrau/2efb8bd98812c4fb4eb6638b4b1dca97 to your computer and use it in GitHub Desktop.
Save nsrau/2efb8bd98812c4fb4eb6638b4b1dca97 to your computer and use it in GitHub Desktop.
create a dynamic data to test
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