Linked Questions

Popular Questions

Passing a json object to a webapi

Asked by At

I have a webapi that accepts data like a list.It is actually an array of objects which I stringify with json like this

        const result = JSON.stringify(values);

Data looks like this.

        const values = [
                  {
                    invoiceAmt: 25.00,
                    Quantity: 60,
                    price: 32.44,
                    PurchaseDate: "2/7/2019 "
                  }, {
                    invoiceAmt: 26.00,
                    Quantity: 50,
                    price: 25.45,
                    PurchaseDate: "1/7/2019"
                  }
                ]     

I need to pass this data(result) to the Detailslist section below.

How can I pass this type of data to my webapi below ?

        AXIOS_AUTHED.post(`${API}/customer-info/myrequest`, {     
                "details": {
                  "InvoiceNumber": 123456,
                  "Reason": "This is awesome",
                  "Amount": 450.00,
                  "Detailslist" : [{
                    "invoiceAmt": "",
                    "Quantity": "",
                    "price": "",
                    "PurchaseDate": ""
                  }]
                },
                "modifiedBy": "Test"
              })

Related Questions