Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postMessageToChannel promise returns undefined #129

Open
mastef opened this issue Jul 9, 2019 · 1 comment
Open

postMessageToChannel promise returns undefined #129

mastef opened this issue Jul 9, 2019 · 1 comment

Comments

@mastef
Copy link

mastef commented Jul 9, 2019

bot.postMessageToChannel('channelname', "Some message", params)
	.then(function(data) {
		console.log("slack data", data);
		return data;
	});

data should be the information regarding the posted message, right? But currently I'm just receiving undefined.

I've reviewed the code, and it seems the callback checker is hijacking the return value in https://github.com/mishk0/slack-bot-api/blob/master/index.js#L388-L394

After adding an else { return data.value; } to handle the case where cb is not defined it works for me:

        return this[method](name).then(function(itemId) {
            return this.postMessage(itemId, text, params);
        }.bind(this)).always(function(data) {
            if (cb) {
                cb(data._value);
+           }else{
+               return data._value;
+           }
        });
@mastef
Copy link
Author

mastef commented Jul 9, 2019

It might be slightly related to #37 except that the message gets posted here successfully. Just the return value in the promise is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant