Unable to call any response commands inside a Promise .then
See original GitHub issueHi, I’m a little new to Node so please be gentle.
What am I doing wrong below… I’m just simply request Alexa to say the result of a request-promise.
Your thoughts and advice greatly appreciated.
var rp = require('request-promise');
var ENDPOINT = 'http://httpd.apache.org/server-status?view=json'
app.launch(function(req,res) {
var options = {
uri: ENDPOINT,
transform: function (body, res, resolveWithFullResponse) {
return JSON.parse(body);
}
};
rp(options)
.then(function (bodyObj)
{
res.say(bodyObj.server.host);
});
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
Promise.prototype.then() - JavaScript - MDN Web Docs
The then() method of a Promise object takes up to two arguments: callback functions for the fulfilled and rejected cases of the Promise....
Read more >node.js - Promise not resolving in https call - Stack Overflow
In the implementation I am using promises but the problem is that the first then is not executed at all. I first call...
Read more >Using .then(), .catch(), .finally() to Handle Errors in Javascript ...
Note: Javascript works by reading the code first, then running it. If your code is invalid, for example being syntactically incorrect from having...
Read more >Node.js v19.3.0 Documentation
Awaits the asyncFn promise or, if asyncFn is a function, immediately calls the function and awaits the returned promise to complete. It will...
Read more >Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. When a promise rejects, the control jumps to the closest rejection handler.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The code was correct, but you were using an older version of alexa-app (2.1.0) that doesn’t support promises. Fix with a working express example in https://github.com/kenibarwick/helloKeni/pull/1.
Thanks for you help, that indeed did fix it