I tried to fetch the value from the object on Fastify but while I was trying to do so, when I make GET
request, it keeps loading and network request keep on pending.
Here is how I tried,
I want to access the property of the object (token) and assign it to new variable, and then I tried to make GET
request on browser and it is keep loading and network is pending
.
Here is my code written on Fastify
inside the controller section.
+ Controller
section
exports.getConversations = async (req, reply) => {
try {
var conversationId = this.authentication();
const { token } = conversationId;
return token;
} catch (err) {
throw boom.boomify(err)
}
}
Here is the object I got from the response of this.authentication()
:
{
"conversationId": "LMFeL1yqdkfjskkkd2kO5-n",
"token": "token_value",
"expires_in": 3600
}
Here is the routes which in inside the routes folder under the src directory:
+ Route
section
const streamController = require('../controllers/streamController');
const routes = [
{
method: 'GET',
url: '/api/stream/converstations',
handler: streamController.getConversations
// schema: documentation.schema
},
{
...
}
]
module.exports = routes;
Can anyone help me out? Thank you in advanced.