Roy G
Roy G

Reputation: 949

a new object throw "Unexpected token." nodejs

I try to create a new object from a class and it returns error "Unexpected token ."

but when I create it as a singleton class and export the object it's work

import {GoogleSheet} from "../modules/googleSheet";

class List {
  constructor(){
    this._googleSheet =  new GoogleSheet('siteList');
  }
}

var GoogleClient = require('./googleClient');
export class GoogleSheet extends GoogleClient{

    constructor(sheet){
        super();
    }
}

Upvotes: 2

Views: 318

Answers (1)

mel-mouk
mel-mouk

Reputation: 98

The issue come from this block :

class Listes {
 new GoogleSheet('siteList')
}

If you want a Listes object to contain a GoogleSheet object when instanciated, you will need to do something like :

class Listes {
   constructor() {
      this.googleSheet = new GoogleSheet('siteList');
   }
}

Upvotes: 2

Related Questions