AI智能
改变未来

项目中Axios简单封装,接口地址Api写活

Axios文件

import Axios from \'axios\'Axios.defaults.baseURL = \'http://101.200.243.213:8767\'export default Axios

api —> Order

export class Order {getOrder=\'/order/DealSelectUserOrder\'selectOrder=\'/order/DealSelectOrderBy\'OrderDetail=\'/order/OrderInfo\'AddLogistics=\'/order/DealAddLogistics\'}

使用时:

import Axios from \"../../Axios\";import Api from \'../../api/Index\'
search=(page)=>{Axios.post(Api.order.selectOrder,{page:this.state.pageSize,pageSize:page,order_deaId:this.props.user.user.role_id,order_goodsName:this.refs.title.state.value,order_creteTime:this.state.dateString,order_logisticsStatus:this.state.SearchSelectData}).then((response)=>{if (response.data.code==-1){this.setState({data:[],total:\'\'})}else {let data = response.data.data.map((item)=>{item[\"key\"] = item.order_number;return item;});this.setState({data:data,total:response.data.count})}})}
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » 项目中Axios简单封装,接口地址Api写活