http.js 702 B

123456789101112131415161718192021222324252627282930
  1. const axios = require('axios')
  2. axios.defaults.adapter = require("axios/lib/adapters/http");
  3. const axiosGet = function (url, params) {
  4. return new Promise((resolve, reject) => {
  5. axios
  6. .get(url, {
  7. params,
  8. })
  9. .then(res => {
  10. resolve(res);
  11. })
  12. .catch(err => {
  13. reject(err);
  14. });
  15. });
  16. }
  17. const axiosPost = function (url, params) {
  18. return new Promise((resolve, reject) => {
  19. axios
  20. .post(url, params)
  21. .then(res => {
  22. resolve(res);
  23. })
  24. .catch(err => {
  25. reject(err);
  26. });
  27. });
  28. }