我想创建与其他用户聊天的对话框并在quickblox聊天历史上设置消息,所以当我使用quickblox.chat.dialog.create(params,(err,createdDialog))api创建对话框时,出现错误如下所示:
err {code: 422,
status: "error",
message: {…},
detail: {…}}
code: 422
detail: base: ["Forbidden. Need user."]
createdDialog null
我的代码是:
console.log("chat password", window.localStorage.getItem('password'));
quickblox.init(this.CREDENTIALS.appId, this.CREDENTIALS.authKey, this.CREDENTIALS.authSecret);
quickblox.createSession({ login: this.user.login, password: this.user.password }, (err, result) => {
console.log("result", result);
quickblox.chat.connect({ 'userId': this.qbUser_Id, 'password': window.localStorage.getItem('password') }, (err, roster) => {
console.log("chat err", err);
console.log("chat roster", roster);
console.log("this.occupentsId", this.occupentsId);
var params = {
type: 'Conversation',
occupants_ids: this.occupentsId
};
quickblox.chat.dialog.create({type: 3, occupants_ids: this.occupentsId}, (err, createdDialog) => {
console.log("err", err);
console.log("createdDialog", createdDialog);
console.log(err);
if (err) {
console.log("iff err", err);
} else {
console.log("else createdDialog", createdDialog);
}
});
// let filters = null;
// quickblox.chat.dialog.list(filters, function(err, resDialogs) {
// if (err) {
// console.log(err);
// } else {
// console.log("resDialogs", resDialogs);
// }
// });
// if (err) reject(err); else {
// resolve();
// }//else
});//chat connect
});
我需要解决方案来获得响应并解决禁止的需要用户的错误,那我该怎么办?