Discord.js Getting data from a json file returns “undefined”

I’m trying to access data from a orders.json file it should list all “orders” however it says “undefined” when i try to do that as shown in the pic below
image
it also does the same thing when there aren’t any “orders” in the json file
image
the list command’s code:

const fsn = require("fs-nextra");
const Discord = require('discord.js');
module.exports = {
    name: 'list',
    description: 'List of all orders',
    aliases: ['allorders'],
    execute(message) {
        

        fsn.readJSON("./orders.json").then((orderDB) => {
            let orderString;
            for(let x in orderDB) {
                orderString = orderString + "`" + x + "`: " + orderDB[x].status + "\n";
                // add newline character at the end to display each "order" on a separate line
            }
            const exampleEmbed = new Discord.MessageEmbed()
                .setTitle('Here\'s a list of the current orders and their status.')
                .setDescription(orderString)
                .setTimestamp()
                .setFooter(message.member.user.tag, message.author.avatarURL());
            message.channel.send(exampleEmbed);
        });
    }
}

data in the json file are stored like this:

{
    "tip": {
        "orderID": "tip",
        "userID": "734532125021307001",
        "guildID": "745409671430668389",
        "guild": "Cybers Taco Stand Server",
        "channelID": "746423099871985755",
        "order": "a",
        "customer": "Aro#1221",
        "status": "Unclaimed",
        "ticketChannelMessageID": "not set"
    },
}

Should it be orderDB[x].tip.status?

no no no the orders.json file contains orders with random letters “tip” is one of the orders and i want the command to list them all from the json file

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.