/** * Created by PengLing on 2017/7/3. */ 'use strict' const request = require('superagent'); class AxyReq { constructor(root) { this.apiRoot = root } get(url) { return request.get(`${this.apiRoot}${url}`); } post(url, data) { return request.post(`${this.apiRoot}${url}`).set('Content-Type', 'application/json').send(data) } put(url, data) { return request.put(`${this.apiRoot}${url}`).set('Content-Type', 'application/json').send(data) } delete(url) { return request.del(`${this.apiRoot}${url}`) } } module.exports = function (app, opts) { const req = new AxyReq(opts.waterUrl) app.fs.waterReq = req }