CodeWithHarry / iNotebook-React

INotebook is a React Application for managing personal notes on the cloud
343 stars 193 forks source link

help needed #24

Open RAHULBAWA777 opened 2 years ago

RAHULBAWA777 commented 2 years ago

POST http://localhost:5000/api/notes/addnote 400 (Bad Request)

VM275:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

I am getting these two errors ...please anyone help.

pavan2108 commented 2 years ago

hello @RAHULBAWA777 can you clearly describe the error.

RAHULBAWA777 commented 2 years ago

hello @RAHULBAWA777 can you clearly describe the error.

Bro everything is working great only when I'm trying to add a note I'm getting error... Because my request is being send in xml format idk why... I have mentioned json format in code still I'm getting that error

pavan2108 commented 2 years ago

can you share code snippet of your api request

RAHULBAWA777 commented 2 years ago

Screenshot (250) Screenshot (251) Screenshot (252) Screenshot (253) Screenshot (254)

here you go man ....please do come up with a solution man!!!

RAHULBAWA777 commented 2 years ago

can you share code snippet of your api request

check out these ss

pavan2108 commented 2 years ago

@RAHULBAWA777 I was unable to repoduce the error can you drop your github repo link so I will try with it

RAHULBAWA777 commented 2 years ago

@RAHULBAWA777 I was unable to repoduce the error can you drop your github repo link so I will try with it

here you go - https://github.com/RAHULBAWA777/cloudbook

pavan2108 commented 2 years ago

@RAHULBAWA777

Their is issue in code it is working fine now

I have replaced the following function

addNote in file src/context/notes/NoteState.js

const addNote = async (title, description, tag) => {
    // API CALL
    // console.log()
    const response = await fetch(`${host}/api/notes/addnote`, {    
   method: 'POST',
      headers: {
        "Content-Type": "application/json",
        "auth-token": localStorage.getItem('token')
      },
      body: JSON.stringify({"title": title, "description": description, "tag": tag}) // body data type must match "Content-Type" header
    });
    const note =await response.json();

    setNotes(notes.concat(note))
  }

I have changed the body

RAHULBAWA777 commented 2 years ago

@RAHULBAWA777 I was unable to repoduce the error can you drop your github repo link so I will try with it

here you go - https://github.com/RAHULBAWA777/cloudbook

bro you a saviour thank you so much .... throw me your social ...i wanna talk

pavan2108 commented 2 years ago

@RAHULBAWA777 I was unable to repoduce the error can you drop your github repo link so I will try with it

here you go - https://github.com/RAHULBAWA777/cloudbook

bro you a saviour thank you so much .... throw me your social ...i wanna talk

Bro My discord handle is pavan#8786 we can connect their

rubulgithub commented 1 year ago

i need a help...

pavan2108 commented 1 year ago

Hello @rubulgithub can you ask your question

pavan2108 commented 6 months ago

Screenshot (86)

Hi @annanayaggarwal please refer to earlier comments if not solved check the network tab for exact error.. we can connect over discord pavanakurathi or pavansssai2001@gmail.com

annanayaggarwal commented 6 months ago

ok sure