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);
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'.