You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Also, it is always recommended to check beforehand if your data is undefined or not. So, the best way to do is like below-
import get from ‘lodash/get’;
const modifiedArray = uniqBy((get(headers, ‘response.data’, [])),’group’);
Considering headers array is part of your api and the path is response.data.headers.
Please Note: You need to install lodash as your dev dependency in your project. uniqBy method will show only unique values without any duplication.
You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Also, it is always recommended to check beforehand if your data is undefined or not. So, the best way to do is like below-
import get from ‘lodash/get’;
const modifiedArray = uniqBy((get(headers, ‘response.data’, [])),’group’);
Considering headers array is part of your api and the path is response.data.headers.
Please Note: You need to install lodash as your dev dependency in your project.
You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Also, it is always recommended to check beforehand if your data is undefined or not. So, the best way to do is like below-
import get from ‘lodash/get’;
const modifiedArray = uniqBy((get(headers, ‘response.data’, [])),’group’);
Considering headers array is part of your api and the path is response.data.headers.
Please Note: You need to install lodash as your dev dependency in your project. uniqBy method will show only unique values without any duplication.
You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Also, it is always recommended to check beforehand if your data is undefined or not. So, the best way to do is like below-
import get from ‘lodash/get’;
const modifiedArray = uniqBy((get(headers, ‘response.data’, [])),’group’);
Considering headers array is part of your api and the path is response.data.headers.
Please Note: You need to install lodash as your dev dependency in your project.
You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Please Note: You need to install lodash as your dev dependency in your project.
You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Also, it is always recommended to check beforehand if your data is undefined or not. So, the best way to do is like below-
import get from ‘lodash/get’;
const modifiedArray = uniqBy((get(headers, ‘response.data’, [])),’group’);
Considering headers array is part of your api and the path is response.data.headers.
Please Note: You need to install lodash as your dev dependency in your project.
You can alternatively use lodash/uniqBy to achieve this. If you are working on enterprise level application and using React/Angular, it’s worth considering. You can achieve the desired result in one line like below-
import uniqBy from ‘lodash/uniqBy’;
const modifiedArray = uniqBy(headers,’group’);
Please Note: You need to install lodash as your dev dependency in your project.