Back

TypeError: Cannot read properties of undefined (reading 'endpoint')

  • 0
  • Web
MUNNA
23 Jul, 2024, 03:52

I've been trying to create document and upload a file. In both cases, this error is shown.

I don't really know what to put here since the error is shown in 'storage.ts'.

Here is my submitHandler function.

`const submitHandler = async (data) => { data.preventDefault(); try { const file = await service.uploadFile(image);

TypeScript
  if(file) {
    const fileId = file.$id
    
    const document = await service.createDocument({slug},
      postName,
      content,
      fileId,
      status,
      userData.$id
    );

    if(document) {
      navigate(`/post/${document.$id}`)
    }
  }`

I didn't bother to search how to write code here. Sorry for that.

TL;DR
Error message 'TypeError: Cannot read properties of undefined (reading 'endpoint')' is shown while trying to create a document and upload a file. The issue seems to come from 'storage.ts'. Check the 'submitHandler' function and make sure 'image' is defined and passed correctly to 'service.uploadFile'.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more