Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter the data in the server-side #42

Open
IsraaSulaiman opened this issue Jul 25, 2019 · 0 comments
Open

Filter the data in the server-side #42

IsraaSulaiman opened this issue Jul 25, 2019 · 0 comments

Comments

@IsraaSulaiman
Copy link

IsraaSulaiman commented Jul 25, 2019

const handleData = (request,response) => {
const endpoint = request.url;
const filePath = path.join(__dirname, "data.json");
fs.readFile(filePath, (error, data) => {
if (error) {
console.log(error);
} else {
response.writeHead(200, { "Content-Type": "application/json" });
response.end(data);
}
});
}

Why do you send the entire json file to the client-side on each change to the input?

You could have filtered the data in the server and returns only the required results to the client-side since the file is too big and it is time-consuming to do filtering in the client-side. This will result in a very bad experience since the user has to wait too long until the results are rendered to the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant