パッケージのリクエスト-axios jsonp



Request Package Axios Jsonp



import JsonP from 'jsonp' import axios from 'axios' import { Modal } from 'antd' export default class Axios { static jsonp(options) { return new Promise((resolve, reject) => { JsonP(options.url, { param: 'callback' }, function (err, response) { if (response.status === 'success') { resolve(response) } else { reject(response.messsage) } }) }) } static get(url,params){ let potions = {} potions.url = url potions.method = 'get' potions.data = params || '' return this.ajax(potions) } static post(url,params){ let potions = {} potions.url = url potions.method = 'post' potions.data = params || '' return this.ajax(potions) } static ajax(options){ let baseApi = 'http://182.48.119.121:8085' return new Promise((resolve,reject)=>{ axios().then((response)=>{ if(response.status=='200'){ var res = response.data if(res.success){ resolve(res) }else{ Modal.info({ Title: 'tip', content:res.msg }) } }else{ reject(response.data) } }) }) } }