score:1

Accepted answer

it looks like the problem is that no response is sent for the happy path on your server. see if this works. if this doesn't fix it, include the code where the db parameter is defined and passed as an argument to searchtextindex.

const searchtextindex = (req, res, db) => {
    const { query, collection } = req.body;

    db.collection(collection).find(
        { $text: { $search: query } }
    )
    .project({ score: { $meta: 'textscore' } })
    .sort({ score: { $meta: 'textscore' } })
    .toarray((err, result) => {
        if (err) {
           console.log(err);
           res.send({ type: 'server_error' });
           return;
         }

         console.log(result);
         
         // need to be sure you send the response
         return res.json(result);
    })
}


Related Query

More Query from same tag