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

SDK api post returns undefined when error #89

Open
unexpand opened this issue Aug 12, 2019 · 4 comments
Open

SDK api post returns undefined when error #89

unexpand opened this issue Aug 12, 2019 · 4 comments

Comments

@unexpand
Copy link

unexpand commented Aug 12, 2019

When using SDKs API, I make a post request. Tried async / await as well but no way can I get a handle error returned by request.

api
.post("users.create", {
name: data.name,
email: data.email,
password: data.password,
username: data.username,
roles: ["anonymous"]
})
.then(res => console.log(res))
.catch(error => console.error(error));

I get the following error on logs generated by API but no way can I get a handle on error thrown, all I get is undefined.

[API] POST error (users.create): {
success: false,
error: 'ajskajs is already in use :( [error-field-unavailable]',
errorType: 'error-field-unavailable'
}

@mriedmann
Copy link

Looks like the same problem i had months ago: #79

@TBG-FR
Copy link

TBG-FR commented Oct 1, 2020

I have the same issue, using hubot-rocketchat which is just a "bridge" to the SDK

Code

const addedUser = await robot.adapter.api.post('users.create', { email, name, password, username });

console.log(addedUser);  

Logs

 ERROR [API] POST error (users.create): { success: false,
  error: 'Adding user is not allowed [error-action-not-allowed]',
  errorType: 'error-action-not-allowed',
  details: { method: 'insertOrUpdateUser', action: 'Adding_user' } }

undefined

I didn't added the permission to my bot, so it's normal that I get success = false, but I can't handle the error as I get and undefined object

@AvivBenShoham
Copy link

Did you solve it?

@tolulope-od
Copy link

Has anyone been able to solve this issue.

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

5 participants