0
bitte helfen Sie mir, ich versuche, Remote-Methode auf Loopback-js zu erstellen, wenn meine Callback-Funktion zurückkehrt, zeigt Fehler „Unbehandelte Fehler für die Anforderung POST“ und meine respone Code Rückkehr machen 500 Antwortcode, aber immer noch meine Ergebnisdaten.Nicht behandelte Fehler für die Anforderung POST Loopback JS
Hier ist mein Code
'use strict';
// Define Variable Depedencies Here
var jwt = require('jsonwebtoken')
module.exports = function(Account) {
Account.login = function(username, password, cb) {
var data = {
username: username,
password: password
}
var token = jwt.sign({exp: Math.floor(Date.now()/1000) + (60*60), data: data}, 'secret');
cb(token)
// console.log(token)
}
Account.remoteMethod('login', {
description: ['Login With Your Credentials'],
http: {path: '/login', verb: 'post'},
accepts: [
{arg: 'username', type: 'string'},
{arg: 'password', type: 'string'}
],
returns: {arg: 'token', type: 'string'}
})
};
und das ist mein Fehler:
D:\PROJECT\Backend>node .
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer
Unhandled error for request POST /api/Accounts/login: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDE4NTM2MTYsImRhdGEiOnsidXNlcm5hbWUi
OiJhZG1pbiIsInBhc3N3b3JkIjoiMTIzNDUifSwiaWF0IjoxNTAxODUwMDE3fQ.os6ijfYyF8losGywdnrVKrHW3-DYZFSwlOVUvHyPIOk
Vielen Dank im Voraus