Closed CheoR closed 3 years ago
Similar SO issue. @ajawashington helped resolving issue.
Instead of calling function (with argument) inside an array
for(let i=0; i < num; i ++) {
callCreate.push(createType.callAdd(createType.type))
}
just pass in function name with no parameter
for(let i=0; i < num; i ++) {
callCreate.push(createType.callAdd)
}
then map through your array in Promise.all and apply your argument to it.
Promise.all(createCalls.map(callback => callback(createType.type)))
CAVEAT
This approach will require calling json-server without the -w
flag, else will still create objects but will also get the ERR_CONNECTION_REFUSED
error noted above.
json-server -p 8088 database.json
Ticket MUST be completed before getting help from an instructor
Name: Cheo
Breakout Room: Hackery
Have you searched the other issue tickets? If not, do that first.
REQUIRED Add Tags to Issue Ticket and Assign to Project Board
c46 Help-Thread
project boardBlocker
label if this is stoping you from moving forwardREQUIRED Describe your issue:
REQUIRED Copy/paste any error messages that appear:
Seems like with
-w
, json-server creates the correct amount of objects, but throws warnings. without-w
, json-server creates a random amount of objects or whatever number was last used the last time-w
was used, but with no warnings.REQUIRED What have you googled? (You must have at least 3 links related to your issue)
REQUIRED: What have you tried? Tell us everything you have tried.
REQUIRED: Copy/paste link TO THE FILE on your branch that you are having issues with
Your link: Link
Code Snippet
Current workaround. Note errors received when using
-w