Please go ease, I've only started coding a couple of months ago.
How can I access a variable from the placeOrder route in the match route?
//Get Price//
const placeOrder = (req, res) => {
var symbol = req.query.symbolID.split(" - ")[0].toUpperCase()
console.log(symbol)
finnhubClient.quote(symbol, (error, data, response) => {
const currentPrice = data.c
console.log(currentPrice)
res.send({ currentPrice })
});
};
I want to pass the currentPrice variable to the this route =>
//Match orders
const match = async(req, res) => {
// I want to access the currentPrice variable here //
const { orderType, orderTimeFrameInput, tradeAmount, symbolSearch, kofTimeInput } =
req.body
console.log(req.body.symbolSearch)
const orders = await knex("orderbook_table")
.where({ order_type: "Call" })
.where({ market: symbolSearch })
.select()
console.log(orders)