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);
})
}
Source: stackoverflow.com
Related Query
- AJAX > MongoDB query only works five times, then server stops handling requests, and I can't refresh the page
- Redux Observable throttle Ajax requests only some conditions met
- Typescript Webpack React compilation resulting in read only file system error, but dev server works fine
- Showing only Post That user Posted in Reactjs with Server Side is Node Js, Mongodb
- Socket.io Server Emit only works after server restart
- RTK Query run query only after user stops typing in search field
- mongodb query aggregation, checking how many times a key corresponds to a value
- Handling multiple ajax requests, only do the last request
- Having trouble making AJAX requests to an express server when using React Router
- React query - Why onSubmit only works after the second click
- Trying to write a react hook that will copy a string, then show an alert. It works but only runs once
- Express server stops after 5 GET requests
- Infinite Scroll React component only loading one new slice of objects on scroll down and then stops
- MERN API GET requests return 404's on Heroku, works on local Raspi server
- How to stop 2 times data fetch in SSR (first on server side and then on client side)?
- Checkbox update value only works on false to true, not on true to false, React, mongoDB
- Axios GraphQl query throws internal server error but fetch() works
- ReactJS SyntheticEvent stopPropagation() only works with React events?
- How to start search only when user stops typing?
- How to wait for AJAX response and only after that render the component?
- Handling ajax with React
- Error: useHref() may be used only in the context of a <Router> component. It works when I directly put the url as localhost:3000/experiences
- What is the React equivalent of an Angular directive that only works on attributes?
- How to fetch data only once in a Next.js app and make it accesible to all the app, both in server and client
- useContext only works in stateless functional component
- Maintaining scroll position only works when not near the bottom of messages div
- React: scrollIntoView only works inside of setTimeout
- How to avoid sending multiple duplicate AJAX requests in axios
- React Router: Update only one query parameter instead of replacing all
- Having a public API but only allowing access to requests sent from my website
More Query from same tag
- Redux is dispatching action more than once even if it's dispatched in just one function once
- How to display nested routes in different pages using React Hooks..?
- What is the best way to update object array value in React
- Check if Firebase sign in is successful React.js
- Incorrect integration into React props
- listen for when mouse has stopped moving
- Page becomes unresponsive and getting 404 error in the console
- React - calling the same function from separate onSubmit and onClick events
- Ant Design Table component with editable rows and controlled inputs
- reactjs-jsx count index in map()
- React Tabs content
- Why the file session returning null when trying to test on the browser?
- React TS spread operator
- is this actually mutating state? A bad practice?? - react
- Test failing cases with React, Jest, React-Testing-Library
- What does Markup actually mean in JAMstack?
- How can I set the size of icons in Ant Design?
- Compare Today Date to Reserved Date in ES6 ReactJS
- Remove node and replace with item from an array into the same node location with React
- React: Passing up data from child component into parent does not update values in parent
- How to get id of button clicked in mapped loop in React
- React: how to declare routes inside a component?
- How to change the state of the particular component when it is clicked, using useState in react js?
- Is there a way to combine Webpack modules to decrease file size?
- Error in Component Output by Button Click
- What is service worker in react js
- How to format html properties to vertical list in VSCode
- Invoking a function from a child component in a parent component via callback
- how to get input value with typescript(put request )
- setTimeout function in saga React.js