cannot read property 'default' of undefined

耗尽温柔 提交于 2019-12-24 19:13:49

问题


Getting this error on the this.realm = line below. Not sure why as this code worked when it was formatted as a factory function

import Realm from 'realm';

export default function Db() {
    this.realm = new Realm({
        schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
        path: config.db_path
    });
    logger(2, realm.path);
}

Db.prototype.doOneToMany = function(one, many) {..};

Db.prototype.query = function(model, filter) {..};

Db.prototype.insert = function(model, options) {..};

Db.prototype.del = function(model, obj) {..};

Db.prototype.update = function(obj, options) {..};

Db.prototype.write = function(func) {..};

Db.prototype.close = function() {..};

Error


回答1:


Try by removing "default" keyword it will work fine...

export function Db() {
this.realm = new Realm({
    schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
    path: config.db_path
});
logger(2, realm.path);}

try this...



来源:https://stackoverflow.com/questions/49578503/cannot-read-property-default-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!