在meteor中使用支付,以及与服务器进行数据交互

how to use Meteor.http.call?

Meteor.http is only available on sever side

http模块仅能用于server端。

1,add http

meteor add http

2, 使用wrapAsync封装异步调用

Meteor.methods({
    hello:function(){
        console.log("server");
        var postTest = function (cb) {
            Meteor.http.post("http://app.lawxin.com/version",
                {data: {},headers: {
                    //"content-type":"application/json",
                    "Accept":"application/json"
                }},
                function (error, result) {
                    console.log("content", JSON.stringify(result));
                    cb && cb(error, result);
                });
        };

        return Meteor.wrapAsync(postTest)();
    }
...

  

cb是callback,是必须调用的。cb的格式须是function(error,result){}格式。

3,错误:ERROR whitelist rejection

mobile-config.js:

App.accessRule('*');

  

4,add cordova pingxx plugin 

meteor add cordova:co.airsia.cordova.pingpp@https://github.com/TongChia/cordova-plugin-pingpp/tarball/b7bdf93a7fbda003a8fab44967bfa5fc36488731 

这个插件在添加时需要参数,这样添加:

mobile-config.js:
App.configurePlugin('co.airsia.cordova.pingpp', {
URL_SCHEME: 'meteorionic'
});

5,使用ejson

meteor add ejson

主要方法:

EJSON.parse
EJSON.stringify

6,错误:error charge object

function(error,result)

该方法中返回的result是string格式。

源码:http://vdisk.weibo.com/s/ao-ZYIoZdaYwE

效果图:

原文地址:https://www.cnblogs.com/sban/p/4702799.html