Question: so how can i return the from the function body?

Asked By
Asked At
2017-07-27 20:04:31

Found 15 possible answers.

User Answered At Possible Answer
loganfsmyth 2017-07-27 20:13:47 @lubo You currently have created a chain of promises, that eventually resolves with your value so the promise you created gets returned So instead of axios.get( , you need return axios.get( but then you're not returning the promise, the promise is just lots and eventually garbage-collected you've got that part right, and the return is what makes the promise resolve properly
lubo 2017-07-27 20:19:23 I tried that 10 minutes ago but the result is the same. I get the console log result but nothing on the page I appreciate it thank you for the help it works with it now @lubo uploaded a file: Untitled the other thing i tried is @lubo uploaded a file: Untitled maybe my code is wrong
loganfsmyth 2017-07-27 20:24:30 which one works?
lubo 2017-07-27 20:24:36 the last one it was returning a promise that i could not call
loganfsmyth 2017-07-27 20:25:20 You should never need new Promise unless you're working with an API that uses callbacks, which this does not using new Promise like this is super hard to read and a known antipattern that code should behave the same way pretty much
lubo 2017-07-27 20:27:29 You can try the code yourself you have the client_id and track maybe i did something wrong but the last one worked the ones before it did not
loganfsmyth 2017-07-27 20:28:12 wait the one before it is missing return podcastStats; you had the return in your earlier snippet, I missed that you changed it more
lubo 2017-07-27 20:33:19 that was it yes
neni 2017-07-30 11:29:41 hello the initializer is explicitly turning the surrogate-decoding mechanism off in the absence of u flags ah got it any ideas? that is a surrogate pair an should be treated as a single code point regardless of whether the regex has a u switch or not I mean I'm wondering why doesn't '\ud800'.match(/[\ud800\udc00]/) return null?
ljharb 2017-07-30 17:27:34 code points are new in the language; regexes only respect them with the u flag.
neni 2017-07-31 16:36:37 thanks by the way this is indeed the case for strings, only that the spec expressly states it should be turned off for regexes lacking the u flag they were mentioned in the ES3 spec, so I thought the surrogate pairs are always joined I mean I had no idea that was the case!
ljharb 2017-07-31 16:39:35 that’s just a spec factoring to make it easier they could have written it so the u flag turns it on, instead. but i’m assuming this way was easier
neni 2017-07-31 16:39:54 ^ tried '.throw' and '.return', to no avail of course. like, function *l() { try { while (true) yield 12; } finally { continue; } } is there any way to force a generator end? by the way thanks!
ljharb 2017-07-31 16:41:33 return; ? no oh from the outside
neni 2017-07-31 16:41:51 yeah, apologies for not stating it :confused: that way things like this will hangs the runtime? var [...a] = l() oh thanks!

Related Questions