How to send message to telegram bot api
# workers-help
r
My worker is returning
{ok: false, error_code: 400, description: 'Bad Request: message text is empty'}
when I make an API call to Telegram. However, I don't see any problems with my fetch request within my worker. What am I missing in my fetch function?
Copy code
js
const sendMessage = async (message) => {

  const token = '--'
  const data = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
    method: "POST",
    body: JSON.stringify({
      chat_id: "---",
      text: message
    })
  })

  return await data.json()
}
k
Try adding a
Content-Type: application/json
request header
r
life saver man
the little things, always
thanks!
2 Views