這是節點V18中的獲取代碼:
let response = await fetch(`https://discord.com/api/guilds/${guild_id}/members/${user_id}`, {
method: "PUT",
headers: {
"authorization": `Bot ${bot_token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
access_token: access_token,
}),
});
我得到了400個錯誤的請求,但在郵遞員中我得到了204個空響應(預期結果)
Fetch response
Postman settings
Related resource: https://discord.com/developers/docs/resources/guild#add-guild-member
我嘗試過移除尸體,但也導致了400個錯誤的請求。如果我刪除了標題,我會得到401未授權。我嘗試過在郵遞員中使用硬編碼值,但這也導致了400個錯誤請求。
我預計會發生的是204無內容或201有公會成員在體內。
我使用以下代碼使其工作:
我不知道這是如何或為什么突然起作用的,但還好:)