Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Bug in server.js - SyntaxError: Unexpected end of JSON input #8

Description

@Martian2Lee
      .then(
          (post) => {
              comments.disableByParent(req.token, post)
          })
      .then(
          (data) => res.send(data),
          (error) => {
              console.error(error)
              res.status(500).send({
                  error: 'There was an error.'
              })
          }
      )

should be

        .then(
            (post) => {
                comments.disableByParent(req.token, post)
                res.send(post)
            },
            (error) => {
                console.error(error)
                res.status(500).send({
                    error: 'There was an error.'
                })
            })

other wise console.log(data) before (data) => res.send(data) will get undefined, and if you try .then(res => res.json()) after fetch() in your api.js, you will get SyntaxError: Unexpected end of JSON input.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions