'how to fix this please tell

hello I am new to js made a discord bot and now was making and mc server info command but getting this error const json = await response.json(); ^

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings. at Function.verifyString (/home/runner/js-try3/node_modules/discord.js/src/util/Util.js:416:41) at Function.normalizeField (/home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:544:19) at /home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:565:14 at Array.map () at Function.normalizeFields (/home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:564:8) at MessageEmbed.addFields (/home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:328:42) at MessageEmbed.addField (/home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:319:17) at Object.module.exports.run (/home/runner/js-try3/commands/minecraft/mcserverinfo.js:21:6) { [Symbol(code)]: 'EMBED_FIELD_VALUE'

const fetch = require('node-fetch')
const { MessageEmbed } = require('discord.js');

module.exports.run = async (Client, message, args, prefix) => {
  const Ip = args[0];
  if(!Ip) return
  message.reply('Please provide an Ip of a Minecraft java edition server');

  const response = fetch(`https://api.mcsrvstat.us/2/${Ip}`);
  const json = await response.json();

  if (!json.online) return
  message.reply('Hmm that dint work I guess you entered wrong ip or the server is offline');

  const info = new MessageEmbed()
  .setColor('RANDOM')
  .setTitle((json.hostname || Ip) + "Information")
  .setThumbnail(`https://eu.mc-api.net/v3/server/favicon/${Ip.toLowerCase()}`)
  .addField("Ip:", json.ip || "Unknown", false)
  .addField("Status:", json.online ?
           "Online": "Offline", false)
  .addField("port:", json.port || "Default", false)
  .addField('Version:', json.version || "Unknown", false)
  .addField("Players online:", json.players ? json.players.online : "Unknown", false)
  .addField("Max players allowed tto join at once:", json.players ? json.player.max: "Unknown", false)

  if(json.motd && json.motd.clean && json.motd.clean.length > 1)
    info.addField("Description:", json.motd.length >200? `${json.motd.clean.slice(0, 200)}...` : json.motd.clean);

  message.reply( { embeds:[info] } )
  
      }

module.exports.help = {
  name: 'mcserverinfo',
  aliases: []
}

is there anymethod to fix this or any other method instead of .json can we use something else



Solution 1:[1]

fetch returns a promise, resolve the promise by using await

const fetch = require('node-fetch');
const response = await fetch(`https://api.mcsrvstat.us/2/${Ip}`);
const json = await response.json();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Azer