-
-
Notifications
You must be signed in to change notification settings - Fork 35.1k
Closed
Labels
wrong repoIssues that should be opened in another repository.Issues that should be opened in another repository.
Description
=====================================
- 10.1.0:
- Windows 10:
- Vs Code, NodeJs, Javasctipt with async:
I am trying to use this with my Firebase projects with NodeJs in Javascript. ESLint doesnt show any errors either. My problem is also extremely similat to this one:-
https://stackoverflow.com/questions/46776835/firebase-async-function-syntax-error?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
What ever I do my node keeps on throwing an error at the word "async". Where ever in my code async appears it gives me an error, like:
================
Is there a syntax error in your code?
Detailed stack trace: /user_code/index.js:36
async function go() {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at getUserFunction (/var/tmp/worker/worker.js:388:24)
==========================================
Version: 10.1.0
Platform: 64-bit (Windows)
Subsystem: "Async"
=========================================
const functions = require('firebase-functions');
exports.apnaNo1 = functions.https.onRequest((request, response) => {
go();
response.send("woohhhoooooo2");
});
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
async function go() {
try {
// but first, coffee
const coffee = await getCoffee();
console.log(coffee); // ☕
} catch (e) {
console.error(e); // 💩
}
}(edited by @vsemozhetbyt: fix markdown nits)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
wrong repoIssues that should be opened in another repository.Issues that should be opened in another repository.