I have a simple skill which does the following. When LAUNCH-ed, it reroutes to another intent where I am trying to connect a database which is on subratasarkar.com
and fetch some user information form there. My code in app.js
is like this:
app.setHandler({
LAUNCH() {
return this.toIntent("LinkAccountIntent");
},
async LinkAccountIntent() {
var request = require("request-promise");
await request({
method: "POST",
uri: "https://subratasarkar.com/actions.php",
json: true,
data: {
action: "json_data"
}
}).then(body => {
//const data = JSON.parse(body);
//this.ask(data.user.name);
console.log(body);
});
}
});
But I always get body
as undefined
.
But when I am making the same request using jQuery in a simple html
file, it works. I get the data back from the server and could PARSE is fine. The JSON structure coming from the server is like the following:
{
user: {
email: "[email protected]"
id: "amzn1.account.XXXXXXXXXXXXXXXXXXXXX"
name: "Jenny Morrison"
}
}
I added webhook.jovo.cloud
in my MySql access list already to make sure it can connect the database remotely. No luck!
What is the right way to call a third party API url using request
and then collect it inside promise
? Please suggest.