I'm written an express function to perform a GET request on a mongo atlas database collection. However, upon testing it in Postman I get the following error logged:
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster.
I've configured my database IP whitelist so that it can take requests from any IP, as follows:
Network Access -> EDIT -> Access list Entry: 0.0.0.0/0.
Any suggestions as to why it isn't working?
Here's the express route:
app.get('/api/all-reviews', (req,res) => {
Review.find()
.then((result) => {
res.send(result)
})
.catch(err => {
console.log(err)
})
})
Here's the model
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const reviewSchema = new Schema({
userName:String,
stars:String,
title:String,
photo:String,
blurb:String
}, {timestamps:true})
const Review = mongoose.model('review', reviewSchema)
module.exports = Review
And here's a sample of the data being returned:
id:5ff59a7a027e312bb815b3c4
userName:"testuserName"
stars:"1"
title:"title"
photo:"photoURL"
blurb:"blurb"
createdAt:2021-01-06T11:09:46.505+00:00
updatedAt:2021-01-06T11:09:46.505+00:00
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…