-2
I am consuming an external API with Request in an application made with adonisjs, to request
is done normally and is returning the statusCode
and body
but I cannot return to my API.
I want to return the same value that comes from the external API in the same pattern without any treatment:
const Request = require('request');
class MyAppController {
async index({ response, auth }) {
Request('https://domain.com/v1/, function (error, res, body) {
console.log(res.statusCode);
console.log(body);
return response.status(res.statusCode).json({ body });
});
}
}
module.exports = MyAppController
Note: in the excerpt spoke a quotation marks in the path of the URL, but this is not the problem
– Jcsreisjr
If a quote is missing fix.
– Augusto Vasques