#not able to get JSON data outside the fs.readFile()

21 messages · Page 1 of 1 (latest)

finite flintBOT
#
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
faint thunder
#

how did you define fs?

#

oh wait nvm

#

misread

#

that fs is the callback async version, you can't extract data out of it

urban hare
#

I just want to get an array out of it

#

been trying for hours

faint thunder
#

use the synchronous, or preferably the promise async version instead

urban hare
#

I used callback

#

yet didn't work

faint thunder
#

yeah you're not supposed to

urban hare
#

i am not much familiar with node.js

#

what do i have to change in that code ?

faint thunder
urban hare
#

Will do

faint thunder
#

then you can use fs' promise api

urban hare
#

I have to download util package ?

faint thunder
#

no

urban hare
#

will try

#

@faint thunder gives me this