I have a React component that has to do a find({}) query with two parameters to a MongoDB database.
const likes = await Likes.find({ postId: postId, userId: userId }).exec()
As Mongo code only works on the server I have to make an API call (I'm using NextJS). This API call is obviously a GET request. How do I pass 'postId' and 'userId' to the get request using SWR (or fetch)?
I was trying to pass them as an object through the 'body' but I don't think this is the correct way at all.
const likesPerUser = {
    postId: postId,
    userId: userId
}
const docs = await fetch('/api/likes/user', {
    method: 'GET',
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
        },
    body: JSON.stringify(likesPerUser),
})
I don't have access to the URL query string
I have a feeling I may be way off key here. Any help would be very much appreciated. Cheers, Matt
 
     
    