Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No login storage #82

Closed
jonra1993 opened this issue Aug 6, 2021 · 2 comments
Closed

No login storage #82

jonra1993 opened this issue Aug 6, 2021 · 2 comments

Comments

@jonra1993
Copy link

I am trying to use this lib to have access to my mega files, but when I try to log in I also get null. Also I received and warning email from Mega. Please can you help to know what I am doing wrong?

const options = {email: '[email protected]', password: 'xxxxx'}
const storage = new mega.Storage({email: '[email protected]', password: 'Asterisco123', autologin: false})
await storage.login((result)=>{
console.log('result', result)
})

@qgustavor
Copy link
Owner

You're trying to use promises, this library use callbacks (because it was created before promises were a huge thing). The first argument from callbacks is the error, which in your case is null as there is no error.

Well, I don't know why you're creating an options object and not using it. You don't need to use autologin: false unless you need to change something related to the connection (like setting up a proxy). Some basic example:

const { Storage } = require('megajs')
const storage = new Storage({
  email: process.env.MEGA_EMAIL,
  password: process.env.MEGA_PASSWORD
})
storage.on('ready', () => {
  // do something with storage, like...
  storage.upload('hello world.txt', 'hello world', error => {
    if (error) return console.error(error)
    console.log('the file was uploaded')
  })
})

Check the storage test case for more examples (it uses autologin: false to change the default gateway with the testing one, but in most cases it's not needed), megajs-cli code (it also uses autologin: false, but to set up a proxy).

Notice that there are plans to rewrite this library using promises and TypeScript. Would be great if you can contribute in some way.

@jonra1993
Copy link
Author

jonra1993 commented Sep 9, 2021

Hello, @qgustavor thanks for your comments. Upgrade this lib sounds good I have some experience with Typescript which is the plan to start rewriting, How can I help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants