'How to fetch discord member list

I'm trying to fetch the member list of a discord server. The Discord bot is inside the server and has admin permission. I'm referring to this part of the documentation Discord Docs.

const response = await fetch(`https://discord.com/api/guilds/685509789178003502/members`, {
            headers: {
                Authorization: `Bot ${botToken}`
            }
        })
var currentUser = await response.json()

This is the response I'm getting {"message":"Missing Access","code":50001} I checked it like a million times and the bot has admin perms 100%.



Solution 1:[1]

Enable Members Intent

Further Reading: https://gist.github.com/advaith1/e69bcc1cdd6d0087322734451f15aa2f

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman