Turns out it answers 204 in production, so let's fix that. Also, let's improve example.html's response handling.

This commit is contained in:
Felipe Cotti 2024-10-05 10:42:33 -03:00
parent 37f94ed1db
commit 8e164be0d7
2 changed files with 4 additions and 5 deletions

View file

@ -23,7 +23,7 @@ public class MessageController : ControllerBase
}
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> Insert([FromBody] InsertMessageRequestDto message, CancellationToken token)

View file

@ -141,13 +141,12 @@ document
body: JSON.stringify(data),
});
const result = await response.json();
if (response.ok) {
if (response.status >= 200 && response.status <= 299) {
alert("Note added successfully!");
this.reset(); // Clear the form fields
} else {
alert(result.errorMessage);
const problem = await response.json();
alert(problem);
}
});
</script>