object Object at handleError graphql

object Object at handleError graphql


0

I am creating a react app using amplify and graphql

my graphql schema is

 type Note @model @auth(rules: [ { allow: public } ] ){
  id: ID!
  name: String!
  description: String
  image: String
  noteBook: NoteBook!
}

type NoteBook @model @auth(rules: [ { allow: public } ] ){
  id: ID! 
  name: String! 
  notes: [Note!] 
}

I have three buttons and these are their associated functions,
Create Notebook

async function handleCreateNoteBook(){
const data = {
  name: 'my 1st notebook'
}
await API.graphql({
  query: createNoteBook,
  variables: {input: data}
})

}

Create Note

 async function handleCreateNote(){
    const data = {
      name: 'test',
      description: 'this is a test note',
      noteBook: 'my 2nd notebook'
    }
    await API.graphql({
      query: createNoteMutation,
      variables: {input: data}
    })

  }

Show Notes

async function handleShow(){
    const noteBookData = await API.graphql({query: listNoteBooks})
    const notesData = await API.graphql({query: listNotes})
    console.log(noteBookData)
  }

However,
while creating a new note,
I am getting the following error

[object Object]
at handleError (https://localhost:3000/static/js/bundle.js:80145:58)
at https://localhost:3000/static/js/bundle.js:80168:7

I am new to graphql. What seems to be the issue?

Share

1

  • that [object Object] means, you are trying to perform an operation on that object Object without converting that to the expected data type! Try doing JSON.parse(noteBookData).

    – Harsh Tuwar

    59 mins ago


Load 2 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *