Uncaught (in promise) TypeError: Converting circular structure to JSON only in my put calls
I recommend you to fix the controller route
[Route("api/[controller]/[action]")]
[ApiController]
public class UsersController : ControllerBase
{
....
public async Task<IActionResult> PutUser([FromBody]Users user)
{
var existedUser = await _context.Users.FindAsync(user.UserId);
if (existedUser == null)
{
return NotFound();
}
_context.Entry(existedUser).CurrentValues.SetValues(user);
try
{
await _context.SaveChangesAsync();
}
catch (ex)
{
return BadRequest(ex.message);
}
return Ok();
}
and javascript
const updateAPIData = (userId) => {
axios.post(`https://localhost:44373/api/Users/putUser`, {
userId: userId,
firstName: firstName,
lastName :lastName,
emailAddress :emailAddress,
phoneNumber : phoneNumber,
password: password
}).then(() => {
navigate('/ReadUser')
})
}