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:
parent
37f94ed1db
commit
8e164be0d7
2 changed files with 4 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue