How to get the last price of an order in a variable

My code is as it follows:

const Binance = require('node-binance-api');
const binance = new Binance().options({
  APIKEY: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
  APISECRET: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'

const repeating = async () => {

  let lastPrice = await binance.allOrders("XRPUSDT", (error, orders, symbol) => {

      if(error) return console.log(error.body)
      console.log('Looking last price for ' + symbol)
      console.log('Last price: ' + orders[0].price)

    }, {limit:1});


And the console gives me:

Looking last price for XRPUSDT order

Last price: 0.53960000

I want to use the value “orders[0].price” outside the function and store it in a variable if possible for future use, like this:

let buyPrice = orders[0].price await"XRPUSDT", buyQuantity, buyPrice, {type : 'LIMIT'}).then(resp => console.log(resp)).catch(err => console.log(err.body)), (error, response) => { if ( error ) return; console.log("Limit Buy response: ", response); console.log("order id: " + response.orderId); }

Inside the async function of course. The think is if I try to show on console the variable “lastPrice” it shows as undefined

  1. This is a nodeJS question. lastPrice won’t get value from await binance.allOrders. Please find a nodeJS forum for further help
  2. Let me remind you about the API-related part. For market orders, you’d find price to be ‘0’. You need to use executedQty/cummulativeQuoteQty to calculate the avg price if the order has been filled

Thanks for your time. I’ll check it in another forum