Error in Javascript forEach

Asked 5 months ago, Updated 5 months ago, 10 views

Creating an API using nodejs

const func=require('./func');
conditions = [item1, item2,...];
const data={};


    for (leti=0;i<items.length;i++) {
         [items[i]]: wait func.getData(items[i])

            item : wait func.getData(item)




When turning the loop for an array of items, such as the one above, the following error occurs only for each item:

[item]:wait func.getData(item,30)

SyntaxError: Unexpected identifier

What is the cause of this?
func defines a group of functions in a separate file and exports async function.

javascript node.js

2022-09-30 11:20

1 Answers

It seems that async is required for forEach callback.

keywords.forEach(async(item, index, self)=>{}

2022-09-30 11:20

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.