title: SyntaxError: Unexpected token function in async function?
body: <p>Hi everyone I'm beginner in Nodejs and mongoose.I have tried to insert and retrieve the data in mongoose.I'm using <strong>async await</strong> function to <strong>execute one by one (sequence)</strong>.can anyone help me? Thanks in advance....</p>
  
  <p>i.e: I want to execute (Async await)concept (SEQUENCE STEP)</p>
  
  <p>1.connect the db</p>
  
  <p>2.create the user</p>
  
  <p>3.find the user.</p>
  
  <p>I'm getting the error :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>async function calltaskone(){
        ^^^^^^^^
  SyntaxError: Unexpected token function
      at Object.exports.runInThisContext (vm.js:78:16)
      at Module._compile (module.js:543:28)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:488:32)
      at tryModuleLoad (module.js:447:12)
      at Function.Module._load (module.js:439:3)
      at Module.runMain (module.js:605:10)
      at run (bootstrap_node.js:420:7)
      at startup (bootstrap_node.js:139:9)
      at bootstrap_node.js:535:3
      
      
      Code for your reference:
      
      
      'use strict';
  
  const mongoose=require('mongoose');
  
  
  const calldbconnect=()=&gt;{
      return new Promise((resolve,reject)=&gt;{
          if(true){
              mongoose.connect('mongodb://vdsd:vdwdwh12dw3,@ds11dwdw.mlab.com:1w5664/vorganisation',{useNewUrlParser:true},(err,db)=&gt;{
                  if(err){
                      console.log(err);
                      reject('Db is not connected');
                  }
                  else{
                      resolve('Db is connected');
                  }
              });
          }
      });
  }
  
  const schemadesign=new mongoose.Schema({
      clientName:String,
      clientId:Number,
      clientAddress:String
  });
  
  
  const modeldata=mongoose.model('clientInfo',schemadesign);
  
  const data=[{
      clientName:'VIGNESH Mack',
      clientId:4128,
      clientAddress:'UK'
  },{
      clientName:'VIGNESH Tokyo',
      clientId:4988,
      clientAddress:'USA'
  }];
  
  function calldatasave(){
  
      return new Promise((resolve,reject)=&gt;{
  
          modeldata.create(data,(err,a,b)=&gt;{
              if(err){
                  reject(`Error occured while data saved ${err}`);
              }
              else{
                  resolve('Data saved successfully');
              }
          });
             
      });
  }
  
  const calldatafind=()=&gt;{
  
      return new Promise((resolve,reject)=&gt;{
  
          if(true){
              console.log('try to find');
              modeldata.find({'clientId':4988},(err,data)=&gt;{
                  if(err){
                      reject(`Error occured while find data: ${err}`)
                  }
                  else{
                      console.log(data);
                      resolve('Data found');
                  }
              });
          }  
      });
  }
  
  async function calltaskone(){
  
      const a=await calldbconnect();
      console.log(a);
      const b=await calldatasave();
      console.log(b);
      const c=await calldatafind();
      console.log(c);
  
  }
  
  calltaskone();</code></pre>
  </div>
  </div>
  </p>