http.js 538 B

1234567891011121314151617181920212223
  1. import { baseURL } from "./base.js";
  2. export const request = (option) => {
  3. return new Promise((resolve, reject) => {
  4. console.log(baseURL + option.url);
  5. uni.request({
  6. url: baseURL + option.url,
  7. method: option.method,
  8. data: option.data,
  9. Headers: {
  10. // "Authorization":window.localStorage.getItem('token')
  11. },
  12. success: (res) => {
  13. console.log(res);
  14. resolve(res);
  15. },
  16. fail: (error) => {
  17. console.log(error);
  18. reject(error);
  19. },
  20. });
  21. });
  22. };