Let's add a network request to the app to save the completed essay. This gist provides a little API client that you should copy into your project and mocks network requests. Here's the deal:
- There should be a button next to "start over" on the essay review screen labeled "save".
- It should pass the text of that reviewed essay, including any user edits, to the endpoint.
- You should not be able to save a blank essay.
- To contrive a test case where the backend rejects the essay, the endpoint will reject any essay containing the phrases "love to laugh", "work hard, play hard", or "partner in crime".
- Upon saving and getting an error, the user should see the error message returned by the server.
- Upon successfully saving, the user should see a confirmation message (e.g., "Your essay has been saved!").
The API client in this gist supports one endpoint, essay, which accepts the following params:
{
text: "the text of your essay"
}
It responds with a Promise. If successful, it will resolve with the object { success: true }, and if it fails, it will reject with a JavaScript Error.