Skip to content

I think there is an issue with the renderFormPage function #3

@engmoe88

Description

@engmoe88

Hi Kyle!
I think there is an issue with this function
async function renderFormPage(res, book, form, hasError = false) { try { const authors = await Author.find({}) const params = { authors: authors, book: book } if (hasError) { if (form === 'edit') { params.errorMessage = 'Error Updating Book' } else { params.errorMessage = 'Error Creating Book' } } res.render(books/${form}, params) } catch { res.redirect('/books') } }
On this commit. Here is the repro steps:
1- Start your server (after you have pulled the changes from the commit mentioned above
2- Go to "Add Book" and click it
3- Don't fill in any of the fields and click "Create"

Actual Result:
The browser will keep loading and nothing happens and then the app will crash.

Expected Result:
The app should redirect the user back to the /books/new page and populate all of the fields that were populated at the initial creation of the book. In my case where non of the fields was populated it should bring me back to the /books/new page and all fields should be empty.

Thanks!
Mohammed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions