Sep 11 19:36
Object literals don’t create a scope nor do they create a this value.
 
Apr 24, 2023 11:20
"The error on the "last" line a red-herring. It's caused by errors further up. This is common in programming." — This is one reason it is a good idea to use small functions and define them so they aren't nested. It makes it easier to test them independently, to indent code so it is readable, and to name them to make the code easy to follow.
Apr 24, 2023 11:20
Typo: setTimeout((function(){ has an extra (
Apr 24, 2023 11:20
stackoverflow.com/questions/2846283/… — The parenthesis around the IIFE are trying to call owhw immediately and pass the anonymous function as an argument to it.
 
Apr 11, 2023 01:41
@joey — Storing the file name won't do you any good. You can't get the file from the filename. Even the full file path won't do you any good because its a temporary file that will be cleaned up when the request is complete. You need to process the form submission so that you store the image somewhere sensible before you can think about getting the image to the browser.
 
Mar 22, 2023 00:02
REDACTED isn't JSON so res.json() is going to throw an exception.
Mar 22, 2023 00:02
Please format your code with sensible use of white space and without > characters littering it.
 
Mar 8, 2023 02:48
Well, that's because you're logging the URL once the dynamic import is ready and you're logging the version immediately. Teaching you how to manage asynchronous code is really out of scope for this question.
Mar 8, 2023 02:48
I've identified your other problem and updated this answer.
Mar 8, 2023 02:48
if (argv.colors == true) { — Don't fail to make sure this is actually a test which passed. Add some more debugging information inside the else because it looks like you never reach your import
Mar 8, 2023 02:48
// console.log(chalk.green.bold(' https://nodejs.org')); — Don't comment that out
Mar 8, 2023 02:48
console.log(format === chalk); — Don't do that
Mar 8, 2023 02:48
console.log(chalk); — Don't do that
Mar 8, 2023 02:48
console.log(format); — Don't do that
Mar 8, 2023 02:48
import * as format from 'chalk'; — Don't do that
Mar 8, 2023 02:48
And you've ignored my comments.
Mar 8, 2023 02:48
Also note that if none of the values log then if (argv.colors == true) { might just not be a true statement and you never get inside the if (which is a separate problem but one that blocks you from getting the problem you are asking about, and would explain why you don't see the error messages that I see).
Mar 8, 2023 02:48
1. Throw out all the changes you made since you wrote the question in the first place. 2. Reread this answer paying careful attention to make sure you understand which parts are documentation I'm quoting, which parts are where I explain the significance of that documentation, and which part is the simple one line change that applies the lesson learned from that documentation. 3. Make the simple one line change I advised.
Mar 8, 2023 02:48
sigh. You've deleted and reposted your earlier comment. My comment, starting "It looks like you are trying to copy", still applies.
Mar 8, 2023 02:48
It looks like you are trying to copy the (quoted from MDN) demonstration of how to compare two values to prove equivalences instead of doing the simple change to one line of your code that I advised.
Mar 8, 2023 02:48
That isn't what I advised.
Mar 8, 2023 02:48
@AlexMarienko — It works here: imgur.com/a/1zPsOO1 so I can't tell what you've done wrong trying to follow my instructions.
 
Jan 19, 2022 18:01
The core problem remains: You have failed to clearly explain what you actually want to achieve. See, as I said before, How to Ask
Jan 19, 2022 18:01
@Owl — The code that jsejcksn provided is valid ECMAScript! And you aren't winning friends by insulting people who are trying to help by calling their comments useless.
Jan 19, 2022 18:01
@Owl — The blue box at the top of the page shows that three people voted to close the question, none of the being HelixKruger, and it tells you why.
Jan 19, 2022 18:01
Re edit: That looks like the middle bit of a class definition. Either your code isn't a complete minimal reproducible example or you need to read an introduction to classes as you've missed out 80% of what is needed for one. (It might also be the middle big of an object definition or a malformed function definition).
Jan 19, 2022 18:01
@Owl — What is "ES method"? How are you defining it? Why should your node app recognise it? Please read How to Ask and provide a minimal reproducible example (edit the question, don't dump a load of code into the comments)
 
Aug 28, 2021 10:29
@AdamSatriaGunadi — "but not in single process" — That's an implementation issue. What is wrong with calling the function in the completion callback? What actual problem does it create? Is it blocking something? Is it too slow? Does it throw errors?
Aug 28, 2021 10:29
Fundamentally this looks like an xyproblem.info (where Y doesn't make sense at all).
Aug 28, 2021 10:29
@AdamSatriaGunadi — "if looping using multi thread way" — Stop thinking about multithreading. Explain the problem not the implementation.
Aug 28, 2021 10:29
@AdamSatriaGunadi — "Because you call HTTP request more than 1 but together" — Are you trying to get the results from multiple URLs collected together? Or are you trying to performance optimise this so much that the time between Request A getting a NO response to trigger Request B to ask if it is YES yet is too long?
Aug 28, 2021 10:29
@AdamSatriaGunadi — "i don't want single thread loop method like call function again after callback complete" — Threads are an implementation detail you shouldn't think about when writing JavaScript. If you call the function when the callback is complete then it will be non-blocking which is what you should care about. The whole point of JS using asynchronous functions is that they are non-blocking.
Aug 28, 2021 10:29
@Bravo — while + await is also waiting for completion 🤷🏻‍♂️
Aug 28, 2021 10:29
@Bravo — Yeah, but that comes back to waiting for completion of the callback, which was rejected (probably wrongly but ho hum)
Aug 28, 2021 10:29
@Bravo — That would only run it once though, where does the loop come from?
Aug 28, 2021 10:29
"setInterval can do this but i can't trust about the speed" — And you don't want to run it again after a fixed amount of time from the start.
Aug 28, 2021 10:29
So when do you want to run it again? You've told us a lot about what you don't want to do, but not much about what you actually want to do.
Aug 28, 2021 10:29
"without waiting completion callback of function it self" — So you don't want to run it again when the previous instance has finished.
 
May 9, 2021 22:12
We can't tell why the promise returned by doScraping resolves before "//do scraping, this takes some amount of time" has done everything you want it to do.
May 9, 2021 22:12
@nickcoding2 — That just suggests that the code you replaced with "//do scraping, this takes some amount of time" doesn't return what you want it to return. We've no way of debugging that based on what you've given us.
May 9, 2021 22:12
The problem of "getting a value from an asynchronous function" and "knowing that an asynchronous function has finished" is the same problem with the same set of solutions.
 
Dec 10, 2020 08:13
@rags2riches — The code in the question shows that the content-type is application/json so it is a preflighted request.
Dec 10, 2020 08:13
@rags2riches — A POST request with an application/json content-type absolutely should have a preflight request!
Dec 10, 2020 08:13
"I mean - cors request doesn't have any headers because it doesn't have any response." — If it doesn't have any response then how can you see it in the network tab with the response? And when you say CORS request do you mean the preflight request for the subsequent POST request? (I'm assuming not the POST request because the error said the preflight failed)
Dec 10, 2020 08:13
And what response headers does it have?
Dec 10, 2020 08:13
1. Browser makes preflight request. 2. Your code doesn't run this line header("Access-Control-Allow-Origin: *");. — we have no way of knowing why because we don't know what triggers that line
Dec 10, 2020 08:13
Then likely that PHP file isn't executing.
Dec 10, 2020 08:13
"Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present" — You've got code which adds that header, but you haven't shown it in context. It looks like you aren't running it for the preflight request.
Dec 10, 2020 08:13
Quote the complete error message. There are lots of different reasons why something might be blocked by the CORS policy.
 
Sep 11, 2020 12:49
No. It's a huge list. I don't have time for that.