javascript - 如何从 Microsoft Graph 删除成员 API 获取响应代码或状态?
问题描述
我正在使用 Graph API remove member API 从组中删除成员。成功删除后,我没有从 api 得到任何类型的响应。
export async function removeGroupMember(accessToken, groupId, memberId) {
const client = getAuthenticatedClient(accessToken);
client
.api("/groups/" + groupId + "/members/" + memberId + "/$ref")
.delete()
.then((res) => {
console.log(res); //undefined
console.log(res.status); //undefined
});
}
我在文档中读到它不会返回任何响应正文,但它会在成功删除时返回响应代码 204。如何获取响应码?
现在上面的代码正在完成这项工作,我可以使用上面的代码删除一个成员,我在 Azure 门户中进行了验证。但我需要在前端做出某种响应,让用户知道该成员已被删除。用于错误处理目的。我不确定这是 Javascript 问题还是 Graph API、Azure AD 问题。
解决方案
尝试获得原始响应:
export async function removeGroupMember(accessToken, groupId, memberId) {
const client = getAuthenticatedClient(accessToken);
client
.api("/groups/" + groupId + "/members/" + memberId + "/$ref")
.delete()
.responseType(MicrosoftGraph.ResponseType.RAW)
.then((res) => {
console.log(res.status);
});
}
我不确定它是否适用于不返回任何响应正文的删除
推荐阅读
- python-3.x - Python函数对列表中包含的许多元组的数字进行分解
- r - 包“光栅”的安装具有非零退出状态
- c# - 在 ASP .NET MVC 5 图表中的每个条形图上显示标签
- jquery - 反转滚动页面的背景颜色
- angular - 如何使用角度 4 为动态生成的表单设置值
- vba - VBA如何解释更改的文件名
- c# - 在 MVC C# 中使用 ajax 导出 pdf 文件
- typescript - “EpicMiddleware”类型上不存在属性“运行”
, {}, 任何, 动作 >' - arm - SysTick 中断导致执行跳转到 STM32F030 上的 0x1fffxxxx
- algorithm - 确定数轴上内部范围的填充