1

I'm trying to set u a telegram bot whereby when someone makes a post on facebook, the post will be sent to telegram as well. Is there anything wrong with this code in general? I keep getting invalid or unexpected or token even after I have the correct API token and chat ID.

*API token and chat ID must be kept secret

const fetch = require('node-fetch');

let token = "<token*>";
let data = {
  chat_id: "<chat ID*>",
    text: "text"
};
​
(async () => {
  await fetch(`https://api.telegram.org/bot${token}/sendMessage`,
    {
     method: 'POST',
     body: JSON.stringify(data),
     headers: {
       'Content-Type': 'application/json',
       }
     }
   ) 
 })();
Ian Pey
  • 11
  • 2

0 Answers0