3

I am implementing socket.io using laravel pusher in laravel and I have also installed laravel-echo and pusher-js using npm install --save laravel-echo pusher-js in frontend. But getting error when I am trying to execute following code ,

let echo = new Echo({
  broadcaster: 'pusher',
  key: PUSHER_API_KEY,
  cluster: PUSHER_CLUSTER
});

echo.channel('updateMainGrid')
  .listen('UpdateGridData', (e)=>{
    console.log(e);
  });

Please help me to salve this issue.

  • 1
    Do you do `import Echo from "laravel-echo";` before using Echo? – SergkeiM Jan 03 '19 at 12:59
  • 1
    yes , I have already imported It. – Hitendra Patil Jan 03 '19 at 13:05
  • Actually what I have found is when I hover on import { Echo } from 'laravel-echo' then warning comes in popup is `Could not find a declaration file for module 'laravel-echo'. /node_modules/laravel-echo/dist/echo.common.js' implicitly has an 'any' type. Try `npm install @types/laravel-echo` if it exists or add a new declaration (.d.ts) file containing `declare module 'laravel-echo';`ts(7016)`. – Hitendra Patil Jan 04 '19 at 05:29
  • Is the import and declaration is in same scope?, because if it is not, you need to set it to `window.` so it can be accessed globally. – SergkeiM Jan 04 '19 at 10:21
  • yes boss , it's in same scope – Hitendra Patil Jan 04 '19 at 11:29
  • @HitendraPatil did you ever find a solution to this? – ii iml0sto1 May 08 '21 at 03:50

0 Answers0