I'm trying to call super method save()
from child instance.
// ImageKeeper.js
'use strict';
module.exports = class ImageKeeper extends FileKeeper {
constructor(keeperPath, options) {
super(`/${keeperPath}`, options)
this.keeperPath = keeperPath;
}
save(filePath) {
return new Promise((resolve, reject) => {
this
.resolvePath(filePath)
.then(function(fileData) {
var filePath = fileData[0],
mime = fileData[1];
super.save(filePath, mime); // <-- GETTING ERROR HERE
})
.catch(function(err) {
reject(err)
})
})
}
}
// FileKeeper.js
'use strict';
module.exports = class FileKeeper {
constructor(keeperPath, options) {
this.storagePath = path.resolve(`${env.paths.storage}${keeperPath}`);
this.options = options;
}
save(filePath, mime) {
return Promise
...
}
}
I'm getting error:
/src/filekeeper/imagekeeper.js:110
super.save(filePath, mime);
^^^^^
SyntaxError: 'super' keyword unexpected here
If I move super.save(filePath, mime);
in the beginning of save()
method, it works.
I've tried bind context to upper scope:
save(filePath) {
return new Promise((resolve, reject) => {
this
.then((fileData) => { // <-- bind context to upper scope
super.save(filePath, mime);
But I'm getting:
Unhandled rejection SyntaxError: 'super' keyword unexpected here
at processImmediate [as _immediateCallback] (timers.js:374:17)
From previous event:
at /src/filekeeper/imagekeeper.js:106:10
Read this, but no luck.
Any ideas? Thank you.
env
root@8d1024b233c3:/src# node -v
v4.1.1
docker -v
Docker version 1.8.2, build 0a8c2e3