我正在使用nestjs在keycloak中实现创建用户的API。我错过了什么吗? 我这里有2个问题。
undefined
用作名字和姓氏任何人都可以帮助我犯错的地方。
async createOpsUser(body: IUserRepresentation) {
return new Promise(async (resolve, reject) => {
// url: http://localhost:9080/auth/realms/master/users
const bodyReq = {
firstName: body.firstName, // getting undefined
lastName: body.lastName, // getting undefined
enabled: true,
};
const auth = await this.getAdminAuth();
const req = {
url: `${this.baseUrl}/realms/${this.realmName}/users`,
auth: {
bearer: auth.access_token,
},
body: bodyReq,
method: 'POST',
json: true,
};
request(req, (err, resp, payload) => {
if (err) {
return reject(err);
}
if (resp.statusCode !== 204) {
return reject(payload);
}
resolve(true);
});
});
}