Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var serverActions = {
- sendData: function (data,url) {
- return new Promise(function (resolve, reject) {
- http.post("http://localhost:59297/api/qm/postqm")
- .set('Content-Type', 'application/json')
- .send('lol')
- .end(function (err, res) {
- if (err == null && res.ok) {
- Dispatcher.handleAction({
- actionType: messageConstants.SHOW_MESSAGE,
- data: okMessage,
- error: false
- });
- resolve(true);
- }
- else {
- Dispatcher.handleAction({
- actionType: messageConstants.SHOW_MESSAGE,
- data: errMessage,
- error: true
- });
- reject(false);
- }
- })
- })
- },
- getData: function (url) {
- return new Promise(function (resolve, reject) {
- http.get(url)
- .end(function (err, res) {
- if (err == null && res.ok) {
- console.log('ok');
- resolve(true);
- }
- else {
- console.log('bad',err);
- Dispatcher.handleAction({
- actionType: messageConstants.SHOW_MESSAGE,
- data: errMessage,
- error: true
- });
- reject(false);
- }
- })
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement