Good evening. My task is to create a website with react that will list through github users. I was following this instruction: https://docs.github.com/en/rest/users/users#get-a-user (for JS). My credentials:
async function searchUsers() {
try {
const octokit = new Octokit({
auth: 'ghp_MY_PERSONAL_TOKEN',
acceptstring: 'application/vnd.github.v3+json'
})
const response = await octokit.request(`GET /users/${name}`, {
username: 'maria98kgm'
});
setUsers(response.data);
setLoading(false);
searchRepos();
}
catch(e) {
setLoading(false);
setUsers('notFound');
console.error('no such a user');
}
}
Whenever i use it too long or push changes to github, it stops working and gives me 401 Unauthorized error:

I cannot solve it for two days already, please help.