I can't think of anything
I know this is a array but node js is recognize it as object in innarflightInfo fn data supposed to be array but it is a object why?
You can see I
console.log(typeof data)
console.log(data)
IN THE IMAGE.
const innarflightInfo = (data) => {
const flightd = []
console.log(typeof data)
console.log(data)
data?.map((fdata,i) => { // GIVING ERROR
const flight = {}
flight.companyId = fdata?.flightInformation?.companyId?.marketingCarrier || ''
flight.operatingCarrier = fdata?.flightInformation?.companyId?.operatingCarrier || ''
flight.dateOfDeparture = fdata?.flightInformation?.productDateTime?.dateOfDeparture || ''
flight.timeOfDeparture = fdata?.flightInformation?.productDateTime?.timeOfDeparture || ''
flight.dateOfArrival = fdata?.flightInformation?.productDateTime?.dateOfArrival || ''
flight.timeOfArrival = fdata?.flightInformation?.productDateTime?.timeOfArrival || ''
flight.from = fdata?.flightInformation?.location[0]?.locationId || ''
flight.fromTerminal = fdata?.flightInformation?.location[0]?.terminal || ''
flight.to = fdata?.flightInformation?.location[1]?.locationId || ''
flight.toTerminal = fdata?.flightInformation?.location[1]?.terminal || ''
flight.flightOrtrainNumber = fdata?.flightInformation?.flightOrtrainNumber || ''
flight.equipmentType = fdata?.flightInformation?.productDetail?.equipmentType || ''
flight.electronicTicketing = fdata?.flightInformation?.addProductDetail?.electronicTicketing || ''
flightd.push(flight)
})
return flightd
}
const flightInfo = (data) => {
const flights = {}
data?.map((fdata,i) => {
flights.FlightNo = fdata?.propFlightGrDetail?.flightProposal[0]?.ref || ''
flights.flightDetails = innarflightInfo(fdata?.flightDetails)
})
console.log(flights)
return flights
}