krakenjs / post-robot

Cross domain post-messaging on the client side using a simple listener/client pattern.
Apache License 2.0
741 stars 92 forks source link

Getting Error: when doing async communication #118

Open soniAnkur opened 1 year ago

soniAnkur commented 1 year ago

Hi, I am getting following error when raising 'test' event.

image

On sender


const parent = window.opener;

postRobot.send(parent, 'test', someRandomJSON, { timeout: 5000 }).then((event) => {
        output.innerText = `Got async response from parent:, ${JSON.stringify(event.data, null, 4)}`
      }).catch(error => {
        console.log(error);
      });

on receiver

postRobot.on('test', (event) => {
                return fetch('https://jsonplaceholder.typicode.com/posts/1')
                    .then(response => response.json())
                    .then(json => {
                        return json;
                    })
            });

Could someone help me with whats causing the issue/how to fix

thanks