question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to call any response commands inside a Promise .then

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
dblockcommented, Feb 9, 2017

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.

0reactions
kenibarwickcommented, Feb 10, 2017

Thanks for you help, that indeed did fix it

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found