request.js 359 B

123456789101112131415161718
  1. import config from '@/config'
  2. const baseUrl = config.baseUrl
  3. export const myRequest = (option = {}) => {
  4. return new Promise((reslove, reject) => {
  5. uni.request({
  6. url: baseUrl + option.url,
  7. data: option.data,
  8. method: option.method || "GET",
  9. success: (result) => {
  10. reslove(result)
  11. },
  12. fail: (error) => {
  13. reject(error)
  14. }
  15. })
  16. })
  17. }