Skip to content
← Back to Community
How to get profile images from repl.it by username?
Profile icon
DREWNOLT

I'm trying to make a repl involving a login(with repl.it) system, and I want it to show the user's icon. Is there a base url I need to use?(such as, repl.it/api/profile/(USERNAME)/icon?) If not, what other strategy could I use?

Voters
Profile icon
DREWNOLT
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

no, i don't think that's possible. You can't do that using code. Sorry.

Profile icon
tussiez

Solution

I am also lazy :/ so here is the code that should work: (according to @19wintersp )

Note: This is browser JavaScript

function getProfilePic(username){ fetch('https://repl.it/data/profiles/'+username).then((response) => response.json()).then((content) => { // content.icon.url }) }
Profile icon
19wintersp

You were surprisingly close. You can request to "https://repl.it/data/profiles/", and then the profile picture URL is "icon.url". Here's some pseudocode:

getProfilePicture(username) { responseBody = httpRequest("https://repl.it/data/profiles/" + username) responseBody = parseJSON(responseBody) return responseBody.icon.url }
Profile icon
DREWNOLT

@19wintersp does this work in node.js? I'm working with node js for this, and that doesn't seem to work...

Profile icon
19wintersp

@DREWNOLT Did you copy-paste my code?

Profile icon
DREWNOLT

@19wintersp yes, but I added "function" to the beginning of it

Profile icon
19wintersp

@DREWNOLT You can't just do that. It was pseudocode. You have to convert it to its NodeJS equivalent.

Profile icon
DREWNOLT

@19wintersp do you know where I can do that?

Profile icon
19wintersp

@DREWNOLT here

Profile icon
DREWNOLT
Profile icon
DREWNOLT

@19wintersp I meant like a link or something...

Profile icon
19wintersp

@DREWNOLT You have to do it. Pseudocode is intended to give you the main structure of the function/program, then you can "port" it to your programming language with your knowledge of it. I'm not going to give you finished source code, but these are practically the same thing:

Profile icon
xxpertHacker

@19wintersp We need a pseudo-code interpreter or VM.

Profile icon
EpicGamer007

@19wintersp https://repl.it/data/profiles/ will not work because of CORS policy

Profile icon
tussiez
Profile icon
19wintersp

@EpicGamer007 CORS does not apply to NodeJS (which is what they are using), and in the case of the browser, you can use a CORS proxy.

Profile icon
EpicGamer007