ошибка при развертывании через безсерверный AWS - PullRequest
0 голосов
/ 10 апреля 2019

Предупреждение о развертывании не может получить ответ при выполнении развертывания sls через aws lamda, поскольку я получаю внутреннюю ошибку сервера

Warning: handler 'getAll' returned a promise and also uses a callback!
This is problematic and might cause issues in your lambda

handler.js using serverless to deploy the rest-api

module.exports.getAll = async(event, context, callback) => {
  context.callbackWaitsForEmptyEventLoop = false;

  connectToDatabase()
    .then(() => {
      Restaurant.find()
        .then(Restaurants => callback(null, {
          statusCode: 200,
          body: JSON.stringify(Restaurants)
        }))
        .catch(err => callback(null, {
          statusCode: err.statusCode || 500,
          headers: { 'Content-Type': 'text/plain' },
          body: 'Could not fetch the Restaurants.'
        }))
    });
};

Serverless: Routes for getAll:
Serverless: GET /restaurant

Serverless: Routes for update:
Serverless: PUT /restaurant/{id}

Serverless: Routes for delete:
Serverless: DELETE /restaurant/{id}

Serverless: Routes for hello:
Serverless: GET /hello

Serverless: Offline listening on http://localhost:3000

Serverless: GET /restaurant (λ: getAll)
=> using new database connection

Serverless: Warning: handler 'getAll' returned a promise and also uses a callback!
This is problematic and might cause issues in your lambda.

Serverless: Warning: context.done called twice within handler 'getAll'!

Serverless: GET /restaurant (λ: getAll)
Serverless: Error while loading getAll
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...