Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. var serverActions = {
  2. sendData: function (data,url) {
  3. return new Promise(function (resolve, reject) {
  4. http.post("http://localhost:59297/api/qm/postqm")
  5. .set('Content-Type', 'application/json')
  6. .send('lol')
  7. .end(function (err, res) {
  8. if (err == null && res.ok) {
  9. Dispatcher.handleAction({
  10. actionType: messageConstants.SHOW_MESSAGE,
  11. data: okMessage,
  12. error: false
  13. });
  14. resolve(true);
  15. }
  16. else {
  17. Dispatcher.handleAction({
  18. actionType: messageConstants.SHOW_MESSAGE,
  19. data: errMessage,
  20. error: true
  21. });
  22. reject(false);
  23. }
  24. })
  25. })
  26. },
  27. getData: function (url) {
  28. return new Promise(function (resolve, reject) {
  29. http.get(url)
  30. .end(function (err, res) {
  31. if (err == null && res.ok) {
  32. console.log('ok');
  33. resolve(true);
  34. }
  35. else {
  36. console.log('bad',err);
  37. Dispatcher.handleAction({
  38. actionType: messageConstants.SHOW_MESSAGE,
  39. data: errMessage,
  40. error: true
  41. });
  42. reject(false);
  43. }
  44. })
  45. });
  46. }
  47. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement