Followed the tutorial up until Part 5 however when I tried to get data from my CosmosDB it does not return a result instead an error of: Failed to load resource: net::ERR_EMPTY_RESPONSE.
I am able to get to the console.log('Getting Heroes...'); on my code for getHeroes below:
function getHeroes(req, res) {
console.log('Getting Heroes...');
const docquery = Hero.find({}).read(ReadPreference.NEAREST).limit(5);
docquery
.exec()
.then(heroes => {
res.status(200).json(heroes);
console.log('Data data has been taken!');
})
.catch(error => {
res.status(500).send(error);
return;
});
}
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Correction I am not able to get to the console.log('Getting Heroes...'); I am able to reach this line of code: this.http.get${api}/heroes)
@jcjp Thanks for the feedback. We are actively investigating and will get back to you soon.
Okay my debugger was able to console.log 'Getting Heroes' twice and then the errors is display on the browser's console.
@jcjp Let me see if an update has been made to this this tutorial and if has been published yet, if not, I will forward on to the content owner to be fixed. Thank you for responding with the issue you are experiencing.
Regards,
Mike
@jcjp A fix was made to this tutorial via Duplicate key error #6955 and Mongoose connection error #6905
Let's hope we have all the issues ironed out.
Hi Mike,
May I ask where could I find the cosmosdb account name? Let's say I have a URI of https://sample.documents.azure.com:443/, is it correct that it is the 'sample' string in the URI?
Hi Mike,
I tried connecting using the mongodb console to my cosmosDB, however I am encountering the following errors:
getaddrinfo(
Unable to reach primary for set
Error: connect failed to replica set
It seems like I am not able to connect to my cosmosDB.
If you are using a Cosmos DB instance deployed in Azure, you need to be aware of what endpoint you have set-up during deployment.
As an example, the following screen capture shows the available API options when deploying a new Cosmos DB instance.

After deploying the Cosmos DB instance, in the Overview blade, you can see the applicable URI values, based upon the API type you have configured during set-up.

So, in the case of https://sample.documents.azure.com:443/, you would replace 'sample' with the instance name you established for the Cosmos DB instance you are using.
Does this information help you?
Regards,
Mike
@jcjp We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.
@Mike thank you for your continued support and it seems that my colleague has set our CosmosDB to use SQL.