2016-03-29 42 views
0

エピローグ(Sequelize ORMのためのNPMモジュールは、エンドポイントを休ま)ので、スパースドキュメントのみ5ヶ月ですが、私はそれのNPMページにhttps://www.npmjs.com/package/epilogueにSyntaxError:予期しないトークンreturn

たこのサンプルミドルウェアモジュールと連携する方法を思っていましたコンソールのエラーが

 return context.continue; 
     ^^^^^^ 

SyntaxError: Unexpected token return 

を読んで、私は認証のためのミドルウェアを追加しようとしていると私は、/ JSをノードに新たなんだとばかりに起動するサンプルコードを貼り付けて、私はこれで作業するかどうかはわかりません。

// middleware.js 
module.exports = { 
    create: { 
    fetch: function(req, res, context) { 
    // manipulate the fetch call 

    console.log('Request URL:', req.originalUrl); 
     next(); 
    }, function (req, res, next) { 

     console.log('Request Type:', req.method); 
     next(); 
    } 

     return context.continue; 
    } 
    }, 
    list: { 
    write: { 
     before: function(req, res, context) { 
     // modify data before writing list data 
     return context.continue; 
     }, 
     action: function(req, res, context) { 
     // change behavior of actually writing the data 
     return context.continue; 
     }, 
     after: function(req, res, context) { 
     // set some sort of flag after writing list data 
     return context.continue; 
     } 
    } 
    } 
}; 
+1

コードを正しくインデントすると、それが正しくない理由がわかります。 – elclanrs

答えて

0

構文が正しくありません。

// middleware.js 
module.exports = { 
    create: { 
    fetch: function(req, res, context) { 
    // manipulate the fetch call 

     console.log('Request URL:', req.originalUrl); 
     console.log('Request Type:', req.method); 


     return context.continue; 
    } 
    }, 
    list: { 
    write: { 
     before: function(req, res, context) { 
     // modify data before writing list data 
     return context.continue; 
     }, 
     action: function(req, res, context) { 
     // change behavior of actually writing the data 
     return context.continue; 
     }, 
     after: function(req, res, context) { 
     // set some sort of flag after writing list data 
     return context.continue; 
     } 
    } 
    } 
}; 
関連する問題