How can I modify my existing Green-Api WhatsApp code to include options for sending both text and media messages?

This topic was automatically generated from Slack. You can find the original thread here.

this is code you helped me to write using Green-Api to send whatsapp:
for (let i = 0; i < students.length; i++) {
const chatId = ${students[i][**this**.whatsapp]}@c.us;
// const message = ${this.content};
const message = this.content.replace(/\/g, ‘’);
console.log(“מספר:”, students[i][this.whatsapp]);

      **try** {
    **await** [axios.post](http://axios.post)(apiUrl, {
      chatId,
      message
    });

now, this one sends only text.
I want to add media messages.
I have the var:
" message_type"
that can be SendMessage for text-only messages, or “SendFileByUrl” for media.

This is example code for sending media:
{
“chatId”: “11001234567@c.us”,
“urlFile”: “https://my.site.com/img/horse.png”,
“fileName”: “horse.png”,
“caption”: “Little horse”
}
now I want to add to my code “if” that checks the var “message_type” and gives the right code for each optin.