2

I'm getting this error {"message":"user is not allowed to do action [find] on [test.postmessages]"}

This is my code

import PostMessage from "../models/postMessage.js";

export const getPosts = async (req, res) => {
    try {
        const postMessages = await PostMessage.find();

        res.status(200).json(postMessages);
    } catch (error) {
        res.status(404).json({ message: error.message });
    }
}
rrieshavv
  • 23
  • 6

1 Answers1

5

This works fine on local mongodb. I guess you are using Atlas. If so, do the follwoing steps:

Go to:

Database Access > Edit (user) > Built-in Role > Change the role to atlasAdmin > update user

I hope this solves your problem.

azam45
  • 306
  • 1
  • 5