请教高手有没有从前端代码反向知晓服务器API接口的数据结构之法

因为只有小程序前端代码,无后端。前端基本逻辑是通过组件calendar.js及其servive.js请求数据,然后index.js获取。已知返回基本数据结构是json(code,data,message)格式,后端自己写个接口获取数据不难,但获得的数据好像不是index.js想要的,不知道有没有前端熟悉一点的大哥能帮忙看一下。

index.js

signEvent: function signEvent(_ref) {
    var detail = _ref.detail;
    this.setData({
        page_type: "day"
    });
    var data = detail.data;
    console.log(data);//打印不出数据来
    if (!(data.activity instanceof Array)) {
        var arr = new Array();
        arr.push(data.activity);
        data.activity = arr;
    }
    if (!(data.notes instanceof Array)) {
        var _arr = new Array();
        _arr.push(data.notes);
        data.notes = _arr;
    }
    var other_arr = {};
    if (data.other.list) {
        data.other.list.forEach(function(data) {
            if (!other_arr[data.name]) {
                other_arr[data.name] = [];
            }
            other_arr[data.name].push(data);
        });
    }
    var list_Arr = [ {
        name: "会议活动",
        data: data.activity,
        type: "activity"
    } ];
    Object.keys(other_arr).forEach(function(key) {
        list_Arr.push({
            name: key,
            data: other_arr[key],
            type: "other"
        });
    });

calendar.js

    dayInformation: function dayInformation(data) {
        var _this3 = this;
        if (this.data.day_sock) {
            return;
        }
        this.data.day_sock = true;
        setTimeout(function() {
            if (_this3.data.day_sock) _this3.data.day_sock = false;
        }, 5e3);
        service.dayInformation(data, function(res) {
            _this3.data.day_sock = false;
            if (res.code == 1) {
                _this3.triggerEvent("signEvent", {
                    data: res.data[data.calendarTime]
                });
            }
        });
    }

service.js

    _createClass(calendarService, [ {
    key: "dayInformation",
    value: function dayInformation(data, cb) {
        return new Promise(function(resolve) {   api.request("api/calendar/CalendarInformation/dayInformation", data, "GET", function(res) {
                resolve(res);
            });
        }).then(function(res) {
            cb(res);
        });
    }
    }
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 4

先在 index.js 中打印一下 data

console.log(data)
 var list_Arr = [ {
        name: "会议活动",
        data: data.activity,
        type: "activity"
    } ];

然后再 service.js 中打印一下返回数据:

   console.log(res)
   cb(res);

对比一下

2年前 评论
yizhu (楼主) 2年前
PFinal南丞 (作者) 2年前
yizhu (楼主) 2年前

Network 里面应该都有把? :smirk:

2年前 评论
yizhu (楼主) 2年前
吊车尾的精灵 2年前
declandragon (作者) 2年前
declandragon (作者) 2年前

伪造,先伪造。一看你就是去扒皮复制

2年前 评论

有办法改前端代码的话可以试试vconsole,如果没有其他好办法就只能看前端代码用了返回结果的什么属性,一点一点找

2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!