unlayer / react-email-editor

Drag-n-Drop Email Editor Component for React.js

Home Page:https://unlayer.com/embed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image export failing

geikobogdan opened this issue · comments

I have my apiKey and project id, but when I try to execute imageExport func I received 401. Attached screenshots with request details (request headers/url, payload). Code:

import { Editor } from "react-email-editor/dist/types"

const EmailEditorNoSSR = dynamic(() => import("react-email-editor").then((mod) => mod.default), { ssr: false })


const projectId = 11111 //your project id


export const EmailBuilderModal: FC<EmailBuilderProps> = ({ open, setOpen }) => {
  const emailEditorRef = useRef<EditorRef | null>(null)

  const onReady = (editor: Editor | null) => {
    if (editor) {
      emailEditorRef.current = {
        editor: editor,
        exportHtml: editor.exportHtml.bind(editor),
      }
      setIsLoading(true)
    }
  }


  const saveImage = async () => {
    if (emailEditorRef.current && emailEditorRef.current.editor) {
      emailEditorRef.current.editor.exportImage(({ design }) => {
        console.log(design, "design")
      }) // 401 error
    } 
  }

  return (
          <EmailEditorNoSSR
              projectId={projectId}
              ref={emailEditorRef}
              onReady={onReady}
            />
         )
})
Screenshot 2024-03-21 at 13 11 47 Screenshot 2024-03-21 at 13 13 18 Screenshot 2024-03-21 at 13 13 32