Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why I keep getting an error when using embed?

I was trying to get a data using Axios, the problem is I always getting an error MessageEmbed field values must be non-empty strings. How can I fix this? This is what I tried

const embed = new MessageEmbed()                 
.setTitle(${res.data.current.condition.text})                 
.setColor("RANDOM")                 
.setThumbnail(https:${res.data.current.condition.icon})                 
.setTimestamp()                 
.setFooter({text: Last Update: ${res.data.current.last_updated}})                 
.addFields(                     
{name: "Location:", value: ${res.data.location.name}, inline: true},                     
{name: "Region:", value:${res.data.location.region}, inline: true},                     
{name: "Country:", value: ${res.data.location.country}, inline: true},                     
{name: "Temperature:", value: ${res.data.current.temp_f}, inline: true},                     
{name: "Wind:", value: ${res.data.current.wind_mph}`, inline: true} )

message.channel.send({embeds: })`

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It might be there’s no data for one of the value in your embed, to prevent this kind of error. You will need to put || "No data" in every value

{name: "Wind:", value: ${res.data.current.wind_mph || "No data"}`, inline: true})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading