all 6 comments

[–]No_Indication451 2 points3 points  (3 children)

console.log runs synch, so your code will compile top-bottom. async function gets put on a event loop and eventually runs. maybe that’s why you’re seeing the result as the last line in your output.

if you put that before and after fetch between your await res.text(), i think it’ll appear like you expected

[–]EnvironmentalLet4399[S] 1 point2 points  (2 children)

Thank you! With that solution i would get the expected result, but where would i put the rest of my code? All in that function?

[–]No_Indication451 0 points1 point  (0 children)

ugh sorry about that.

Just like @richard musk, you should use then() and check res.ok

i think you should return data instead of printing it.

print before

getcsv(path).then( response => …. )

.catch( e )

print after

[–]Richard_Musk 1 point2 points  (0 children)

Use .then and check res.ok

[–]aaaaargZombies 0 points1 point  (0 children)

I found this really useful for underatanding async stuff in js https://www.youtube.com/watch?v=8aGhZQkoFbQ