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]
 | 
					    [HttpPost]
 | 
				
			||||||
    [ProducesResponseType(StatusCodes.Status201Created)]
 | 
					    [ProducesResponseType(StatusCodes.Status204NoContent)]
 | 
				
			||||||
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)]
 | 
					    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)]
 | 
				
			||||||
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
 | 
					    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
 | 
				
			||||||
    public async Task<IActionResult> Insert([FromBody] InsertMessageRequestDto message, CancellationToken token)
 | 
					    public async Task<IActionResult> Insert([FromBody] InsertMessageRequestDto message, CancellationToken token)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -141,13 +141,12 @@ document
 | 
				
			||||||
      body: JSON.stringify(data),
 | 
					      body: JSON.stringify(data),
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const result = await response.json();
 | 
					    if (response.status >= 200 && response.status <= 299) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (response.ok) {
 | 
					 | 
				
			||||||
      alert("Note added successfully!");
 | 
					      alert("Note added successfully!");
 | 
				
			||||||
      this.reset(); // Clear the form fields
 | 
					      this.reset(); // Clear the form fields
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      alert(result.errorMessage);
 | 
					        const problem = await response.json();
 | 
				
			||||||
 | 
					        alert(problem);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
        </script>
 | 
					        </script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue