是否在post api中传递倍数?

问题描述 投票:0回答:1

这是我的post api请求,我需要从前端获取此数据:

enter image description here

考虑下面的代码,users_id实际上是从localStorage获取的,而items_id是从我从componentDidMount调用的另一个api中获取的]]

purchaseOrder(){
        const Users_id = localStorage.getItem('id'); // get user_id
        const items_id = this.state.data.id; // get items_id
        console.log(Users_id)
        console.log(items_id)
        PostData('api/purchase-order-item/submit', this.state).then ((result) => {  // how to pass the users id and items id to api?
            let responseJSON = result;
            console.log(responseJSON);
            console.log(this.state)
            });
    }

this.state:

constructor(props){
  super(props);

   this.state ={
      data: [],
      remark: '', //for api 
      quantity: '', // for api
      isLoaded: false,
      redirect: false,
      history: PropTypes.object.isRequired
   }
    this.purchaseOrder = this.purchaseOrder.bind(this);
     this.onChange = this.onChange.bind(this);
 }

这是我的发布api请求,我需要从前端获取此数据:考虑下面的代码,users_id实际上是从localStorage获取的,而items_id是从另一个被我称为api的api中获取的。

reactjs api message-passing
1个回答
0
投票
首先从状态获取remarkquantity,然后传递一个新的普通对象作为API发布数据:
© www.soinside.com 2019 - 2024. All rights reserved.