一身上の都合により

プログラミングとかの話

VueとExpress(2)

とりあえずログイン処理でも実装してみるか、と思ってMEANスタックを参考に構成中。
参考:express実践入門 · GitHub

methods: {
    login_post(){
        var user = {
            'email': this.email,
            'password': this.password
        };
        axios.post('/api/v1/auth/login' , user ).then(res => {
            console.log(res.data );
        });
    },
}

そしたらAPIコールがVue側の8080ポートに飛んでエラーになった。

POST http://localhost:8080/api/v1/auth/login 404 (Not Found)

このへんを見ると vue-cli-plugin-express がうまいことやってくれるらしいがダメ。
(当然yarnで追加済み)

で、よく見るとExpressがエラーっぽいの吐いている。

  ⏳  Express server is restarting...
(node:32447) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:32447) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:32447) UnhandledPromiseRejectionWarning: /Users/tesstesstex/Work/hogehoge/hogehoge/node_modules/passport-jwt/lib/strategy.js:1
TypeError: JwtStrategy requires a secret or key
    at new JwtStrategy (/Users/tesstesstex/Work/hogehoge/hogehoge/node_modules/passport-jwt/lib/strategy.js:45:15)
    at Object.<anonymous> (/Users/tesstesstex/Work/hogehoge/hogehoge/srv/config/passport.js:22:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
(node:32447) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:32447) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:32447) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.

とりあえずこれを読み解きますか……。