Answer the question
In order to leave comments, you need to log in
How to write route in Hapi+hapi-swagger?
Good afternoon, I decided to learn hapi.js and ran into a situation that was incomprehensible to me.
route looks like:
server.route({
method: 'GET',
path: '/api/user',
config: {
tags: ['api'],
description: 'Get All User data',
notes: 'Get All User data'
},
handler: function (request, reply) {
UserModel.find({}, function (error, data) {
if (error) {
reply({
statusCode: 503,
message: 'Failed to get data',
data: error
});
} else {
reply({
statusCode: 200,
message: 'User Data Successfully Fetched',
data: data
});
}
});
}
});
{
"statusCode": 200,
"message": "User Data Successfully Fetched",
"data": [
{
"_id": "56e5bfa46811f3783b43993a",
"uuid": "sldkgskldfg",
"phone": 48792452359,
"__v": 0
}
]
}
"statusCode": 200,
"message": "User Data Successfully Fetched",
"data": [
Answer the question
In order to leave comments, you need to log in
Why shouldn't they be, you bring them out yourself
reply({
statusCode: 200,
message: 'User Data Successfully Fetched',
data: data
});
{
"statusCode": 200,
"message": "User Data Successfully Fetched",
"data": [
{
"_id": "56e5bfa46811f3783b43993a",
"uuid": "sldkgskldfg",
"phone": 48792452359,
"__v": 0
}
]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question