-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
notes.map is not a function #49
Comments
Hi , I am also facing this issue did you find any solution please help |
1 similar comment
Hi , I am also facing this issue did you find any solution please help |
One way I found is: But after this I am unable to fetch notes on my main page. |
hey you guys can use this code - {Notes ? Notes.map((i) => (
<><p>{i.title}</p></>)) :"No notes available"}
…On Mon, Apr 17, 2023 at 2:13 PM Jawad-Ali2 ***@***.***> wrote:
The code works fine till video#71. But changes in noteState.js
headers: {
'Content-Type': 'application/json',
"auth-token": localStorage.getItem('token')
}
caused this issue. If I remove the localStorage line and write the
previous line (the auth token we used on the endpoint).
Kindly, someone help me with this issue, I've been facing for 1 week now.
Thanks.
[image: image]
<https://user-images.githubusercontent.com/107391644/232431714-540c0546-5ce0-4cde-94c7-5d80f4f6bdff.png>
—
Reply to this email directly, view it on GitHub
<#49>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZIEUL6ZASSTWATSUCCBOLLXBT7DPANCNFSM6AAAAAAXA3OOJU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
hey you guys can use this code - {Notes ? Notes.map((i) => ( <> {i.title} </>)) :"No notes available"} |
hey you guys can use this code - {Notes ? Notes.map((i) => ( <> {i.title} </>)) :"No notes available"} |
I tried using them and the problem was solved but my addnote through frontend getnotes are returning 401 bad request any help to get through this |
Have anyone resolved it please share |
{notes.length>0? notes.map((note)=>{ No Notes to Display You can use this it just checks whether the notes array length is 0 or greater if its zero is prints no notes to display else it renders all the notes. |
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 authToken in Login.js and Signup.js. hope this will help you |
Here is solution import React, { useContext, useEffect } from 'react'; const Notes = () => { console.log("notes"); useEffect(() => { return ( {!localStorage.getItem("token") ? navigator('/login') : Array.isArray(notes) && notes?.map((note) => { // return {note.title} ;return }) } </> ); }; export default Notes; |
The code works fine till video#71. But changes in noteState.js
headers: {
'Content-Type': 'application/json',
"auth-token": localStorage.getItem('token')
}
caused this issue. If I remove the localStorage line and write the previous line (the auth token we used on the endpoint) the app works fine.
Kindly, someone help me with this issue, I've been facing for 1 week now. Thanks.
The text was updated successfully, but these errors were encountered: