http.js 528 B

12345678910111213141516171819202122
  1. import request from './request'
  2. // 调用的时候第一个参数换成接口地址即可
  3. export function httpGet(url, params) {
  4. return new Promise((resolve, reject)=>{
  5. request.get(url, params).then((result)=>{
  6. resolve(result)
  7. }).catch(err=>{
  8. reject(err)
  9. });
  10. });
  11. }
  12. export function httpPost(url, params) {
  13. return new Promise((resolve, reject)=>{
  14. request.post(url, params).then((result)=>{
  15. resolve(result)
  16. }).catch(err=>{
  17. reject(err)
  18. });
  19. });
  20. }