0

//This is how i'm trying to send[this how it appear in the console ][1]

      const paramz = new URLSearchParams()
         paramz.append('meals',this.state.meals)
                let URLL=`https://localhost:44327/api/AddMealOrderr`
                axios.post(URLL,paramz,config).then(res=>{
        
                    console.log(res)
                    
                }).catch(error=>{
                console.log(error)
                })

} //this is my web api action

public IHttpActionResult PostMealOrder(List<MealOrder> meals)
    {
        
        if (!ModelState.IsValid)
        {
            return BadRequest(ModelState);
        }
        for (int i = 0; i < meals.Count; i++)
        {
         
            db.MealOrders.Add(meals[i]);
        }

        db.SaveChanges();

        return Ok(meals);
    }

[1]: https://i.stack.imgur.com/kYwI8.png*emphasized text*

1 Answers1

0

is the request getting a hit ? adding a breakpoint at the if statement should detect whether the request is being detected at the api or not.

that being said, i dont think you need URLSearchParams since you are issuing a post request you should be looking at FormData()

check this it should help a little bit.