mukund shelke
mukund shelke

Reputation: 423

how do we return sql query result data to caller function in node.js without using ajax?

I am new for node.js . I want to return data of function to caller function. please give me the ways to do it. I want to return mysql query result data to caller function how i do it ? thank you in advance. have a good day.

Upvotes: 0

Views: 529

Answers (1)

rsp
rsp

Reputation: 111336

You cannot return directly any result of the SQL query or any other asynchronous function. Any function that does an synchronous operation in Node.js can either take a callback or return a promise. It cannot return the result of the asynchronous operation to its caller because that result is not available yet at the point when the function returns.

For more info see those answers:

Upvotes: 1

Related Questions