RocketChat / RocketChat/Rocket.Chat.js.SDK

SDK api post returns undefined when error

Open
#89 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
146
Forks
99
Avg merge
7h 59m
Merged PRs (30d)
17

Description

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'
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the SDK API POST for users.create with the shown promise and inspect how the request error is propagated to catch. Trace the POST error handling until the logged structured error is returned to the caller; done means the catch callback receives the error instead of undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.