zoukankan      html  css  js  c++  java
  • 在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

    效果图:

  • 相关阅读:
    「枫桥夜泊」一诗
    走遍亚洲 —— 泰国
    走遍亚洲 —— 泰国
    暴露年龄
    暴露年龄
    插入排序(insertion sort)
    开机黑屏 仅仅显示鼠标 电脑黑屏 仅仅有鼠标 移动 [已成功解决]
    OpenCV For iOS 1: 连接OpenCV 3.0
    插入排序
    [hadoop系列]Pig的安装和简单演示样例
  • 原文地址:https://www.cnblogs.com/sban/p/4702799.html
Copyright © 2011-2022 走看看