Title: unexpected identifier while spinning the server
Tags: node.js;async-await
Question: I am making a simple node js app using MVC.
Here is my model:
const db = require('../util/database');
class Channel {
constructor(channel_id,channel_name, price, language, isActive, genre) {
this.channel_id = channel_id;
this.channel_name = channel_name;
this.language = language;
this.isActive = isActive;
this.genre = genre;
this.price = price;
static fetchAll() {
return db.execute('SELECT * FROM channel');
Here is my controller:
const Channel = require('../models/channel');
class AdminController {
constructor(){
async static getChannels(req,res){
let channels = await Channel.fetchAll();
res.send(channels);
module.exports = AdminController;
Here are my routes:
const express = require('express');
const adminController = require('../controllers/admin');
const router = express.Router();
router.get('/all-channels', adminController.getChannels);
module.exports = router;
But the problem is when I am trying to spin the server, it says unexpected identifier async static getChannels(req,res){
Where am I doing wrong?
P.S. I am new to NodeJs


Here is another answer: first thing you have require your route file inside index.js
like app.use('/', yourRouteFile);
and second one you have change in route file router.route('/data').get(adminController.getChannels);
and static async syntax
I think so now it's helpful for you.
Comment for this answer: yes, my bad, it would be static async. Already corrected it. But I want to encapsulate the prefix. That's why encountered with such a tiny issue. thanks, buddy.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:09/10/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<node.js><async-await>', 'Title': 'unexpected identifier while spinning the server', 'ViewCount': 45, 'id': 57869988, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}