wenlele
12 months ago
5 changed files with 62 additions and 15 deletions
@ -0,0 +1,38 @@ |
|||
/** |
|||
* Created by PengLing on 2017/7/3. |
|||
*/ |
|||
'use strict'; |
|||
|
|||
const request = require('superagent'); |
|||
|
|||
module.exports = { |
|||
entry: (app, router, opts) => { |
|||
const apiRoot = `${opts.host}${opts.match}`; |
|||
const req = { |
|||
get: (url) => { |
|||
return request.get(`${apiRoot}${url}`); |
|||
}, |
|||
|
|||
post: (url, data) => { |
|||
return request |
|||
.post(`${apiRoot}${url}`) |
|||
.set('Content-Type', 'application/json') |
|||
.send(data); |
|||
}, |
|||
|
|||
put: (url, data) => { |
|||
return request |
|||
.put(`${apiRoot}${url}`) |
|||
.set('Content-Type', 'application/json') |
|||
.send(data); |
|||
}, |
|||
|
|||
delete: (url) => { |
|||
return request.del(`${apiRoot}${url}`); |
|||
} |
|||
}; |
|||
|
|||
app.iota = app.iota || {}; |
|||
app.iota.request = req; |
|||
} |
|||
}; |
Loading…
Reference in new issue