9 Replies
may have to await the parse(result)?
no that function is synchrous, and using
writeTextFileSync
doesn't help eitherCan you check if you actually get a string for
name
? The error says that the first argument for writeTextFile
is not a string.horrible error message
If
Promise.all()
is expecting an iterable of promises, technically what you're returning is a composition of a promise and a chained statement. I don't often use Promise.all but I'm betting that fetchPage is generating the promise and passing the promise to the chained .then()
statement, which fails to destructure the name and videos variables.
You probably just need to declare the map callback as async to generate a promise.nah, functions only need to be tagged w/ async if im using await inside them. the map converts all the urls
Array<string>
to Array<Promise<{name:string,videos:Array<Video>}>>
hence why i can use promise.all with it
the name parameter for Deno.writefile
was undefined instead of a string so thats why shit borkedconsole log videos
That was a poor error message indeed. Might need to open an issue for enhancement.
It would be helpful to share the functions you're using inside your snippet.
Whatever object you're destructuring in the
then
statement, the name property isn't always a string, hence the error. You should log the output of the object you're destructuring to confirm this. The solution would be to type check name and videos to ensure that they are the proper types before attempting to write them to a file.
Also I am interested in what this is here