R
Reactiflux

✅ – _mercury – 00-13 Aug 29

✅ – _mercury – 00-13 Aug 29

M_mercury8/29/2022
I have logged group as in the photo I have this code
groups.forEach((group) => {
console.log(group);

return Object.keys(group).forEach((key) => {
if (!group[key]) {
delete group[key];
}
});
});
groups.forEach((group) => {
console.log(group);

return Object.keys(group).forEach((key) => {
if (!group[key]) {
delete group[key];
}
});
});
But these 2 lines do not work
group.templates_count = parseInt(group.templates_count) || 0;
group.attributes_count = parseInt(group.attributes_count) || 0;
group.templates_count = parseInt(group.templates_count) || 0;
group.attributes_count = parseInt(group.attributes_count) || 0;
why ?
M_mercury8/29/2022
full code
groups.forEach((group) => {
console.log(group);
group.templates_count = parseInt(group.templates_count) || 0;
group.attributes_count = parseInt(group.attributes_count) || 0;
return Object.keys(group).forEach((key) => {
if (!group[key]) {
delete group[key];
}
});
});
groups.forEach((group) => {
console.log(group);
group.templates_count = parseInt(group.templates_count) || 0;
group.attributes_count = parseInt(group.attributes_count) || 0;
return Object.keys(group).forEach((key) => {
if (!group[key]) {
delete group[key];
}
});
});
UUUnknown User8/29/2022
2 Messages Not Public
Sign In & Join Server To View
M_mercury8/29/2022
@Timotius
UUUnknown User8/29/2022
2 Messages Not Public
Sign In & Join Server To View
M_mercury8/29/2022
{
"groups": [
{
"id": 8,
"name": "Cases",
"created_at": "2022-08-27T21:28:02.000Z",
"updated_at": "2022-08-27T21:28:02.000Z",
"attributes": [
{
"id": null,
"name": null
}
],
"templates": [
{
"id": null,
"name": null
}
]
}
]
}
{
"groups": [
{
"id": 8,
"name": "Cases",
"created_at": "2022-08-27T21:28:02.000Z",
"updated_at": "2022-08-27T21:28:02.000Z",
"attributes": [
{
"id": null,
"name": null
}
],
"templates": [
{
"id": null,
"name": null
}
]
}
]
}
UUUnknown User8/29/2022
2 Messages Not Public
Sign In & Join Server To View
M_mercury8/29/2022
mmm , it is not the code i seek
UUUnknown User8/29/2022
Message Not Public
Sign In & Join Server To View
M_mercury8/29/2022
they are numbers surronded by quotes I am trying to parseInt them
groups.forEach((group) => {
console.log(group);

return Object.keys(group).forEach((key) => {
group.templates_count = parseInt(group.templates_count) || 0;
group.attributes_count = parseInt(group.attributes_count) || 0;
if (!group[key]) {
delete group[key];
}
});
});
groups.forEach((group) => {
console.log(group);

return Object.keys(group).forEach((key) => {
group.templates_count = parseInt(group.templates_count) || 0;
group.attributes_count = parseInt(group.attributes_count) || 0;
if (!group[key]) {
delete group[key];
}
});
});
I have did that BUT it works for attributes_count BUTTTTTT templates_count disappears , i dunno why
{
"id": 8,
"name": "Cases",
"created_at": "2022-08-27T19:28:02.000Z",
"updated_at": "2022-08-27T19:28:02.000Z",
"attributes": [
{
"id": null,
"name": null
}
],
"templates": [
{
"id": null,
"name": null
}
],
"attributes_count": 0
}
{
"id": 8,
"name": "Cases",
"created_at": "2022-08-27T19:28:02.000Z",
"updated_at": "2022-08-27T19:28:02.000Z",
"attributes": [
{
"id": null,
"name": null
}
],
"templates": [
{
"id": null,
"name": null
}
],
"attributes_count": 0
}
UUUnknown User8/29/2022
Message Not Public
Sign In & Join Server To View
M_mercury8/29/2022
thx for effort BUT i am also doing that
if (!group[key]) {
delete group[key];
}
});
if (!group[key]) {
delete group[key];
}
});
UUUnknown User8/29/2022
Message Not Public
Sign In & Join Server To View
M_mercury8/29/2022
bc the value is null
UUUnknown User8/29/2022
4 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

✅ – _mercury – 00-13 Aug 29

Join Server