request.js 349 B

1234567891011121314151617
  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. }