Advertisement
Guest User

Untitled

a guest
Mar 27th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. $.ajax({
  2. url: "//localhost:3000/api/tokens",
  3. type: "POST",
  4. data: JSON.stringify({
  5. user: {
  6. email: 'admin@admin.com',
  7. password: 'password123'
  8. }
  9. }),
  10. contentType: "application/json"
  11. })
  12. .then(data => data.token.encoded) // OK
  13. .then(token => Farmbot({ token: token })) // OK
  14. .then(function(bot){ // OK
  15. return new Promise(function(resolve, reject) {
  16. bot.connect(function(){ resolve(bot); });
  17. });
  18. }, errorr)
  19. .then(function(bot){ // NOT OK!
  20. // passes in an unresolved promise object, which is useless.
  21. //
  22. bot; // => {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement