使用数组过滤数据
const pickupData = [
{
id: 2876635,
pickup_location: "6311cdacf6b493647d86",
address_type: null,
address: "999, Jagarati",``
address_2: "Vihar",
updated_address: false,
old_address: "",
old_address2: "",
city: "Meerut",
state: "Uttar Pradesh",
country: "India",
pin_code: "250001",
email: "938@gmail.com",
is_first_mile_pickup: 0,
phone: "76898",
name: "Aa",
company_id: 2889808,
gstin: null,
vendor_name: null,
status: 2,
phone_verified: 1,
lat: null,
long: null,
warehouse_code: null,
alternate_phone: null,
rto_address_id: 2867270,
lat_long_status: 0,
new: 1,
associated_rto_address: null
},
{
id: 2872407,
pickup_location: "6311cdad490cf6b493647d82",
address_type: null,
address: "Nagar",
address_2: "Delhi",
updated_address: false,
old_address: "",
old_address2: "",
city: "Bijnor",
state: "Uttar Pradesh",
country: "India",
pin_code: "246701",
email: "ima@gmail.com",
is_first_mile_pickup: 0,
phone: "75398",
name: "Amit Sharma",
company_id: 2889808,
gstin: null,
vendor_name: null,
status: 1,
phone_verified: 1,
lat: null,
long: null,
warehouse_code: null,
alternate_phone: null,
rto_address_id: 2867270,
lat_long_status: 0,
new: 1,
associated_rto_address: null
}
];
const shiprocketData = [
{
line1: "999, Jagarati",
line2: "Vihar",
city: "Meerut",
state: "Uttar Pradesh",
pincode: 250001,
country: "India",
isCurrent: true,
_id: "6311cdad490cf6b3647d86"
},
{
line1: "999, Jagarati",
line2: "Vihar",
city: "Meerut",
state: "Uttar Pradesh",
pincode: 250001,
country: "India",
isCurrent: true,
_id: "6311cdad490cb493647d82"
},
{
line1: "999, Jagarati",
line2: "Vihar",
city: "Meerut",
state: "Uttar Pradesh",
pincode: 250001,
country: "India",
isCurrent: true,
_id: "6311cdad490cf693647d89"
}
];
const updatedData = () => {
const data = pickupData.filter(
(item, index) =>
item.pickup_location === shiprocketData.map((item) => item._id)[index]
);
return console.log(data);
};