Alright so I am making a project using Hypixel's API, it will fetch all of the friends of a specific (predetermined) user and save their UUIDs to a JSON file. Sadly, due to Hypixel having a poorly maintained API there is a glitch that causes the target player's uuid to show up in the JSON file multiple times. Does anybody know how to use node edit-json-file to check for and remove duplicates?
const fetch = require("node-fetch")
const uuid = "b5cc9c1b-aeb6-4b3d-9ee6-31f608e6e9f0"
const editJsonFile = require("edit-json-file");
let file = editJsonFile(`${__dirname}/filename.json`);
const fetched = (`https://api.hypixel.net/friends?uuid=${uuid}&key=f0f0d96b-4789-4702-b3b7-58adf3015a39`);
fetch(fetched)
.then(res => res.json())
.then(json => {
const friendCount = (Object.keys(json.records).length);
var i;
for (i = 0; i < friendCount; i++) {
file.append("names", { uuid: json.records[i].uuidReceiver });
}
});
file.save();
file = editJsonFile(`${__dirname}/filename.json`, {
autosave: true
});```