Hello, i am trying to query the MongoDB API using the API key as the authentication method, but i keep getting the 401 status code.
Here is the code:
fetch('https://eu-west-2.aws.data.mongodb-api.com/app/application-0-dhdvm/endpoint/mydatabase', {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`, // Include your API key in the Authorization header
},
})
I generated the API KEY:
I created the following EndPoint: https://eu-west-2.aws.data.mongodb-api.com/app/application-0-dhdvm/endpoint/mydatabase
