When I run this code I get error TypeError: Cannot read properties of undefined (reading 'weather'), So how can I access weather data in searchloc post request?
Ah, sorry I haven’t used CJS modules in Node for a fair while, forgot it required actual JS modules (import foo from "./bar" rather than const foo = require("./bar")),
So with what you are using, to make what I posted work, simplest way is to wrap in a self-executing async function, eg:
(async () = {
// Logic here
})();
Or you can use a set of async functions.
Otherwise you need to put the app.post call in another then, otherwise it will try to execute before the promise has resolved – this is how JS works