CodeWithHarry/iNotebook-React

notes.map is not a function Solved here

krcpr007 opened this issue ยท 15 comments

Hii guys many of you are probably facing "notes.map is not function error ", Here I have a solution for you guys, and it's working !!

what you have to do is go to the NoteState.js replace"auth-token": localStorage.getItem('auth-token'); at four places!!
it means you have to replace "token" with "auth-token" everywhere like LoginJs Signup.js Navbar.js NoteState.js, Notes.js !!
also replace this localStorage.setItem('token', json.authtoken); with this localStorage.setItem('auth-token', json.authToken); wherever you used !!
I hope this will help you all guys !!
Happy coding <3

It's working la thanks man <3

Sorry. its not working.!! after changing this in all file.! we have fetchuser.js also in which we had already declared token, and we are matching it and fetching the user.

Its working try to go through your code ones

I have check my code, its working but i didnt change anything, i had used "token" not "auth-token". There is an syntax error.

I have check my code, its working but i didnt change anything, i had used "token" not "auth-token". There is an syntax error.

Did your code worked after changing "token" to "auth-token" in fetchuser.js? cause i have changed it in all files except fetchuser.js.

I have check my code, its working but i didnt change anything, i had used "token" not "auth-token". There is an syntax error.

Did your code worked after changing "token" to "auth-token" in fetchuser.js? cause i have changed it in all files except fetchuser.js.

i did not change any thing, i just go with the "token" as it is showing in harry bhai demo.

Yes, iNotebook app is working fine after changing all the occurences of 'token' with 'auth-token' and authtoken with authToken excpet fetchuser.js. Don't change anything in fetchuser.js file. I hope that will work fine for you.

irf0 commented

Thanks a lot for being so helpful bro it worked for me..๐Ÿ˜Ž

@irf0 Thanks

irf0 commented

@irf0 Thanks

But bro its again showing error It was working sometime ago

@irf0 Thanks

But bro its again showing error It was working sometime ago

What the hell is going on ??

//Use this in your Notes.js

    {Array.from(notes).map((note) => {
      
      return (
        <Noteitem
          key={note._id}
          updateNote={updateNote}
          showAlert={props.showAlert}
          note={note}
       
        />
      );
    })}
  </div>

Yes, iNotebook app is working fine after changing all the occurences of 'token' with 'auth-token' and authtoken with authToken excpet fetchuser.js. Don't change anything in fetchuser.js file. I hope that will work fine for you.

but naw a new problem a can't go to home page with sign in

Hii guys many of you are probably facing "notes.map is not function error ", Here I have a solution for you guys, and it's working !!

what you have to do is go to the NoteState.js replace"auth-token": localStorage.getItem('auth-token'); at four places!! it means you have to replace "token" with "auth-token" everywhere like LoginJs Signup.js Navbar.js NoteState.js, Notes.js !! also replace this localStorage.setItem('token', json.authtoken); with this localStorage.setItem('auth-token', json.authToken); wherever you used !! I hope this will help you all guys !! Happy coding <3

Thanx a lot bro!! It worked...

check your auth.js file and fetchuser.js file in backend. you might have written auth-token. simple write auth-token instead of token in localStorage.getItem('auth-token') in NoteState.js,login.js,signup.js.,Notes.js and Navbar.js. Also replace the json.authtoken with json.authToken in Login.js and Signup.js. hope this will help you