.upload() is not a function? #137
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 20 replies
-
I'm quite confused on what you're trying to do, I don't know your JavaScript background, but seems you are mistaking how asynchronous JavaScript works. Do you know how to use Promises? And how about callbacks? If not check some tutorial for those topics first.
Seems you are using Node CJS, it does not support top level await, check examples in mega.js.org to workaround this limitation (use a async IIFE). If possible learn and use ESM, it does not have this limitation. Try learning about async patterns in JavaScript, them fix the login first, that's a lot for now, I will answer the upload question later.
|
Beta Was this translation helpful? Give feedback.
-
By the way, how to upload file in new folder Can you give an example? |
Beta Was this translation helpful? Give feedback.
I'm quite confused on what you're trying to do, I don't know your JavaScript background, but seems you are mistaking how asynchronous JavaScript works.
Do you know how to use Promises? And how about callbacks? If not check some tutorial for those topics first.
storage.ready
is a Promise, so seems you're missing anawait
keyword, but at the same time you defined a callback at the same time, which… is weird. Use one or another. Callbacks is the old pattern, promises is the new one, this library support both because backyards compatibility but I recommend learning and using promises as they avoid some issues that callbacks have (like nesting hell).Seems you are using Node CJS, it does not s…