hello! im developing lemmy client (on html5). i tried to do login function but... when i try to fetch /v3/user backend with auth-token it give me error:
{
"error": "no_id_given"
}
but why? what im doing wrong? if you want here is my source file on github ( function: getLoggined() )
4 Comments
ptz@dubvee.org · 3 pts · 1y
To get the current logged-in user's details, that's actually retrieved from
/api/v3/sitefor....reasons, I guess?Your function can remain the same, but change the api endpoint to
/siteAlso, the user details will be in themy_userkey from get site response.Is there a reason you're not using the lemmy-js-client? That will take care of a lot of the low-level fetching for you (and has TypeDocs which help you to know what response / form data is needed).
Your Original Function, Slightly Modified
okelote360@lemmy.world · 2 pts · 1y
thanks! it works!
okelote360@lemmy.world · 0 pts · 1y
i didnt use lemmy-js-client because i dont know how to install it in github pages...
flamingos@feddit.uk · 1 pts · 1y
/api/v3/useris for fetching info about any user, it requires either aperson_idorusernameto be given as a URL param to work, e.g.https://feddit.uk/api/v3/user?person_id=28426will get my profile. There currently isn't a way to get just theperson_viewfrom the JWT, though API v4 will have an/accountendpoint that you'll be able toGETwith the auth header. Most appsGETthe/siteendpoint and usemy_userreturned from that.