title: Wait for javascript callback function to finish
body: <p>I am using google storage api for saving a file in gcp bucket in a async function. I want to wait till I get a error or success in callback, only then I want to proceed with other lines of code but I am getting LastMessage before success or error.</p>
  <p><a href="https://googleapis.dev/nodejs/storage/latest/File.html#save" rel="nofollow noreferrer">https://googleapis.dev/nodejs/storage/latest/File.html#save</a></p>
  <pre><code>await file.save(jsonData.trim(), {resumable : false}, function(error) {
   if (error) {
     console.log('error');
   } else {
     console.log('success');
   }
  })
  
  console.log( &quot;LastMessage: Error or Success is received, only then log this message&quot;)
  </code></pre>