showing results for - "await is only valid in async function"
Aitana
19 Nov 2017
1async function start() {
2   ....
3
4   const result = await helper.myfunction('test', 'test');
5}
Stefania
08 Aug 2018
1//If you are using reduce(), the since the result of the first accumulation loop 
2//will be used in the second second loop.so need one more asyc in front of
3// reduce parameters:
4
5const sleep = (n) => new Promise((res) => setTimeout(res, n));
6
7const arr = [1, 2, 3];
8
9const asyncRes = await arr.reduce(ASYNC (memo, e) => {
10	await sleep(10);
11	return (await memo) + e;
12}, 0);
13
14console.log(asyncRes);
15// 6
16//
Leane
13 Oct 2016
1// My function
2const myfunction = async function(x, y) {
3  return [
4    x,
5    y,
6  ];
7}
8
9// Start function
10const start = async function(a, b) {
11  const result = await myfunction('test', 'test');
12  
13  console.log(result);
14}
15
16// Call start
17start();
queries leading to this page
zap nodejs await is only valid in async functionawait is only valid in async functions and async generatorsindex html 3a12 uncaught syntaxerror 3a await is only valid in async functionawait is only valid in async function axiossyntaxerror await is only valid in async function puppeteernode experimental top level await uncaught syntaxerror 3a await is only valid in async function 22await is only valid in async function 22 2cdocref set 28 7b 5e 5e 5e 5e 5e syntaxerror 3a await is only valid in async functionasync is only valid in async function nodejssyntaxerror await is only valid in async function node jssyntaxerror 3a await is only valid in async function mongooseis only valid in async functionfetch await is only valid in async functionawait is only valid in async function javascriptsyntaxerror 3a await is only valid in async function node jsyntaxerror 3a await is only valid in async functionerror await is only valid in async functionsyntaxerror 3a await is only valid in async function in global nodejsnode await syntaxerror 3a await is only valid in async functionjavascript await is only valid in async functionawait is only valid in async function promisepromise await is only valid in async functionawait is only valid in async function c2 a0node jssyntaxerror 3a await is only valid in async function for asyncnode await is only valid in async functionparsing error 3a 27await 27 is only allowed within async functions react jsnode syntaxerror 3a await is only valid in async function 28index 29 3a168 uncaught syntaxerror 3a await is only valid in async function 22syntaxerror 3a await is only valid in async function 22 2cnodejs await is only valid in async functionawait is only valid in async runctions on promisejs await import is only valid in async functionasync in try catch syntaxerror 3a await is only valid in async functionawait is only valid in async function new functionscript js 3a75 uncaught syntaxerror 3a await is only valid in async functionawait with promise all 28 29 gives syntaxerror 3a await is only valid in async functionemployee php 3a219 uncaught syntaxerror 3a await is only valid in async functionawait is only valid in async function erroruncaught syntaxerror 3a await is only valid in async function 22class 22 typescriptawait is only valid in async function within thenawait is only valid in async function not working with mainnode js promise pending await is only valid in async functionawait is only valid in async function forawait is only valid in async function in async functionawait is only valid in async function error in async functionwhat does syntaxerror 3a await is only valid in async function meanawait collection findone 28data 2c 28e 29 3d 3e 7b 5e 5e 5e 5e 5e syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function express jshtml script element with asynchronous javascript function uncaught syntaxerror 3a await is only valid in async functionsawait can only be used within async javascriptawait is only valid in async function jsuncaught syntaxerror 3a await is only valid in async functionawait is only valid in async function node js looplambda syntaxerror 3a await is only valid in async functionscripts js 3a8 uncaught syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in a sync functionawait is only valid in async function lokaliseawait is only valid in async function top leveljs await is only valid in async function 22syntaxerror 3a await is only valid in async function 22express js await is only valid in async functionajax await async await is only valid in async functionawait is only valid in async function node js 15await is only valid in async function workarounddocref set syntaxerror 3a await is only valid in async functionwait is only valid in async functions and the top level bodies of modules 22await is only valid in async function 22syntax error await is only valid in async functionwait is only valid in async functionnode js await is only valid in async functionawait is only valid in async function inside iftry catch syntaxerror await is only valid in async function node await is only valid in async functionode js promise await is only valid in async functionindex html 3a23 uncaught syntaxerror 3a await is only valid in async functiontwilio await is only valid in async functions and async generatorsorder 3a1274 uncaught syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function nodejsnodejs await is only valid async functionawait is only valid in async function sharp jsawait is only valid in async functionsyntaxerror 3a await is only valid in async function not workingsyntaxerror await is only valid in async function moongeawait is only valid in async function with asyncsyntaxerror 3a await is only valid in async function in nodejs 28index 29 3a15 uncaught syntaxerror 3a await is only valid in async functionawait only valid in async functionsimplespec js 3a82 uncaught syntaxerror 3a await is only valid in async functionnode express syntaxerror 3a await is only valid in async functionjs class await is only valid in async functionjs error syntaxerror 3a await is only valid in async functionawait is only valid in async function called on async functionsyntaxerror 3a await is only valid in async function even when its in asyncsyntaxerror 3a await is only valid in asyncjs await is only valid in async functionsawait docref set 28 7b 5e 5e 5e 5e 5e syntaxerror 3a await is only valid in async functionnode js error await is only valid for async functions await is only valid in async functionjavascript function 28next 29 syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function javasyntaxerror 3a await is only valid in async function js fix 22syntaxerror 3a await is only valid in async function 22 lambdaawait is only valid in async function and i have a async functionawait is valid only in async functionsyntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function class methodsyntaxerror await is only valid in async function try catchsyntaxerror 3a await is only valid in async function class mathod 28index 29 3a17 uncaught syntaxerror 3a await is only valid in async function face api jsnode js await is only valid in async function promiseawait open 28 60 60 29 5e 5e 5e 5e 5e syntaxerror 3a await is only valid in async functionnodejs syntaxerror 3a await is only valid in async functionsays await is only valid in async functionawait api login await is only valid in async functionaxios react error index js 3a 27await 27 is only allowed within async functions and at the top levels of modulessyntaxerror 3a await is only valid in async function 5cawait is only valid in async function at wrapsafeawait is only valid in async function fetchawait is only valid in async function nodejs es6await is only valid in async function update queryhow to fix syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function 22 2cnode console uncaught syntaxerror 3a await is only valid in async functiongoerli uncaught syntaxerror 3a await is only valid in async functionalready put await but error await is only valid in async function syntaxerror 3a await is only valid in async functionnode js await is only valid in async functionsyntaxerror 3a await is only valid in async function collection findnode await is only valid in async function on rootawait is only valid in async function while being in asyncsyntaxerror await is only valid in async function javascriptbcrypt syntaxerror 3a await is only valid in async functionawait is only valid in async function node jsawait is only valid in async function nodejsaws lambda syntaxerror 3a await is only valid in async functionwait is only valid in async functions and the top level bodies of modules nodeapp js 3a61 uncaught syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function and i have an async functionawait is only valid for async functionawait is only available in async functionbegintransaction await is only valid in async functionuncaught syntaxerror 3a await is only valid in async function reduce 28 29uncaught syntaxerror 3a await is only valid in async function classuncaught syntaxerror 3a await is only valid in async function class typescripthow to fix await is only valid in async functionawait is only valid in async function but i have a asyncnew html 3a21 uncaught syntaxerror 3a await is only valid in async functionawait is only valid in async function variable awaitnode js syntaxerror await is only valid in async functionsyntaxerror 3a await is only valid in async function but function is asyncsyntaxerror 3a await is only valid in async function promiseerror parsing error 3a 27await 27 is only allowed within async functionsawait is only valid in an async functionclient query await is only for asyncawait is only valid in async function in nodejsawait is only valid in async function even in async functionclass await is only valid in async functionawait is only valid in async function even though in async functionjavascript uncaught syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function in nodejs apiaws sdk syntaxerror 3a await is only valid in async functionawait is only valid in async function ajaxawait is only valid in async function but function is asyncparsing error 3a 27await 27 is only allowed within async functionsawait must be in async functionsyntaxerror 3a await is only valid in async function but funtion is asyncfetch uncaught syntaxerror 3a await is only valid in async functionsyntaxerror 3a await is only valid in async function inside loopjavascript await is only valid in async functionawait is only valid in async function expressjssyntaxerror await is only valid in async functionsyntaxerror 3a await is only valid in async function for an async functionconst 5bresponse 5d 3d await client recognize 28request 29 3b 5e 5e 5e 5e 5e syntaxerror 3a await is only valid in async functionjs syntaxerror 3a await is only valid in async function but its in an asyn functionawait is only valid in async function