Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- url: "//localhost:3000/api/tokens",
- type: "POST",
- data: JSON.stringify({
- user: {
- email: 'admin@admin.com',
- password: 'password123'
- }
- }),
- contentType: "application/json"
- })
- .then(data => data.token.encoded) // OK
- .then(token => Farmbot({ token: token })) // OK
- .then(function(bot){ // OK
- return new Promise(function(resolve, reject) {
- bot.connect(function(){ resolve(bot); });
- });
- }, errorr)
- .then(function(bot){ // NOT OK!
- // passes in an unresolved promise object, which is useless.
- //
- bot; // => {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement