代码之家  ›  专栏  ›  技术社区  ›  Salman

对Mockable.io API响应本机| Axios post请求

  •  0
  • Salman  · 技术社区  · 6 年前

    我正在构建一个react原生应用程序,您可以在其中订购物品。

    • 项目
    • 图标

    但是,我无法发布到我的其他可模拟API(发布的限制)

    我正在使用expo开发我的应用程序

    我期待什么:

    我得到了什么:

    未损坏的承诺拒绝(id:0);错误:网络错误

      handleSubmit = () => {
    
          this.setState({
            orderRestrauntId: this.props.RestrauntId,
            orderValue: this.state.value,
            orderProducts: this.props.products,
            orderTotalPrice: this.props.totalPrice,
    
          })
         axios.post(
        'https://demo3381137.mockable.io/orders', 
        {
          "orderId": "1",
          "RestrauntId": this.state.orderRestrauntId,
          "orderKey": "F3SAR566T",
          "userId": "1",
          "paymentStatus": "approved",
          "preparing": "approved",
          "orderStatus": "approved",
          "paymentMethod": this.state.orderValue,
          "totalPrice": this.state.orderTotalPrice,
          "order": [
              {
              "product" : "burger",
              "qty" : "5"
              },
              {
              "product" : "pizza",
              "qty" : "5"
              },
              {
              "product" : "fries",
              "qty" : "5"
              }
          ]
        },
        {
          headers: {
            'Accept': 'application/json',
             'Content-Type': 'application/json',
          }
        }
        );
    
          console.log('submit');
        }
    
    0 回复  |  直到 6 年前
        1
  •  0
  •   Salman    6 年前

    Gabriele Petrioli在我的url中发现了一个错误 https://http:// ,应该是 https://