AminoJS / Amino.JS

A powerful JavaScript library for interacting with the Amino API :star2:
MIT License
27 stars 5 forks source link

Examples of framework use #63

Closed tvortsa closed 5 years ago

tvortsa commented 5 years ago

Need more examples how to use framework, more than "login" only please !

How i can use getJoinedComs(); for framework mode ?

akatsukilevi commented 5 years ago

In the framework you can use any module The login module were used for example of how to use the framework The Amino.login('email', 'password') can be used for any Amino function

tvortsa commented 5 years ago

"any other modules" require for i must be loged in or not? Where i can get "sid" and where i can write call "any other modules" ?

Excuse me my stupidly ^^

i try somethig like this:

const AminoAPI = new Amino.AminoAPI();
AminoAPI.proccessAction(Amino.login('myemail@gmail.com', 'mypass'), function(data) {
    // Here is the success handler
    console.log('AMINO LOGIN SUCCESSFULL !');
    const sid = AminoAPI.session_Id
    aminos = Amino.getJoinedComs(sid);
    aminos = aminos.coms;
    aminos.map(comminity => {
        console.log(`${comminity.name} | ${comminity.link}| ${comminity.id}`);
    });
    console.log('');

}, function(error) {
    // Here is the error handler
    console.log('AMINO LOGIN ERROR !');
});
akatsukilevi commented 5 years ago

Sorry for late reply And yes, it requires you to be logged in You don't need to get the SID, as it is stored as a setting inside the Amino.JS And not sure if that would work, more because getJoinedComs takes no arguments(you don't need specify the SID anywhere) You can use it like this

AminoAPI.proccessAction([Your action here], function(data) {
// process data here
], function(error) {
// process error here
});

Your code could be re-writed like this:

const AminoAPI = new Amino.AminoAPI();

// do login here
AminoAPI.proccessAction(Amino.login('myemail@gmail.com', 'mypass'), function(data) {
    // Here is the success handler
    console.log('AMINO LOGIN SUCCESSFULL !');
}, function(error) {
    // Here is the error handler
    console.log('AMINO LOGIN ERROR !');
});

// fetch communities here
AminoAPI.proccessAction(Amino.getJoinedComs(), function(data) {
    data.coms.map(comminity => {
        console.log(`${comminity.name} | ${comminity.link} | ${comminity.id}`);
    });
}, function(error) {
    throw new Error(error);
});

EDIT: had wrote the code like AminoAPI.proccessAction was async, but infact it is sync

tvortsa commented 5 years ago

Thank you, unfortunately it work for Login() but not work for fetch by getJoinedComs(), and i get this error:

(node:34716) UnhandledPromiseRejectionWarning: Error: Error: SID is not specified, please use the login() method to authenticate and try again

akatsukilevi commented 5 years ago

So try it like this

const AminoAPI = new Amino.AminoAPI();

// do login here
AminoAPI.proccessAction(Amino.login('myemail@gmail.com', 'mypass'), function(data) {
    // Here is the success handler
    console.log('AMINO LOGIN SUCCESSFULL !', data);
    // fetch communities here
    AminoAPI.proccessAction(Amino.getJoinedComs(), function(data) {
        data.coms.map(comminity => {
            console.log(`${comminity.name} | ${comminity.link} | ${comminity.id}`);
        });
    }, function(error) {
        throw new Error(error);
    });
}, function(error) {
    // Here is the error handler
    console.log('AMINO LOGIN ERROR !');
});

Also check to see if the email and password is valid

tvortsa commented 5 years ago

Eeewhooo! Its work for me now! Thank you very mutch! ^^ (i was use : console.log('${comminity.name} | ${comminity.link} | ${comminity.id}'); but not : console.log(`${comminity.name} | ${comminity.link} | ${comminity.id}`); " ` " not " ' " )

akatsukilevi commented 5 years ago

Glad it worked! And mistakes with `` and '' i do almost always too XD