I have the following json. From the below json I wanted only the PartNumber of each item in the form of an array. Can anyone please help how to do so using filter?
Below is my code. In the console log am getting only the PartNumber of first item
state = {
data: MYResult.Products || [],
partNumbers: []
};
componentDidMount(){
const allPartNumbers = this.state.data.filter(partnumbers =>
this.state.data.PartNumber);
console.log(allPartNumbers)
}
"Products": [
{
"PartNumber": "ALM-GN001",
"ProductName": "GNSS Filter-LNA Front-End Module",
"productline": "GPS/GNSS Wireless Amplifiers",
"AV_47_Frequency_GHz": "1.575",
"AV_47_NF": ""
},
{
"PartNumber": "ALM-GP001",
"ProductName": "GPS Filter-LNA-Filter Front-End Module",
"productline": "GPS/GNSS Wireless Amplifiers",
"AV_47_Frequency_GHz":"1.565 - 1.606",
"AV_47_NF": ""
},
{
"PartNumber": "ALM-GA001",
"ProductName": "High-Gain, Low-Current LNA with Variable Current and Shutdown Function",
"productline": "GPS/GNSS Wireless Amplifiers",
"AV_47_Frequency_GHz": "1.606",
"AV_47_NF": "0.97"
},
{
"PartNumber": "ALM-GN002",
"ProductName": "GNSS LNA-Filter Front-End Module with Optional Differential Outputs",
"productline": "GPS/GNSS Wireless Amplifiers",
"AV_47_Frequency_GHz": "1.565",
"AV_47_NF": "0.97"
}
]