export function postMessage(method: string, body?: any): Promise<any> {
  return new Promise((resolve, reject) => {
    window.addEventListener('message', handler)
    window.parent.postMessage({
      appId: '3syxin',
      method: method,
      body
    }, '*')
    function handler(e: MessageEvent) {
      const { data } = e
      if (data.method === method) {
        resolve({
          method,
          data: data.body
        })
        window.removeEventListener('message', handler)
      }
    }
  })
}
