1

I have an old ES5 JS repo that doesn't accept promises. The error I get is:

'Promise' is not defined no-undef

What should I replace it with? I tries many await/async/callback combinations and failed to make it wait for the cpuCount value to get updated. I've been trying to understand this for years. Can someone help?

var getValue = function(path, defaultValue) {
    return new Promise(resolve => {
        fun1(input1, input2), function(err, result) {
            if (err) {
                resolve(defaultValue);
            }
            resolve(result.Value);
        });
    });
  };
var getCount = async () => {cpuCount = await getValue(KEY, DEFAULT);};
getCount().then(() => {do some stuff}
east.charm
  • 480
  • 1
  • 7
  • 17
  • Can you share a code example that produces this error? The code example you've shared has a bunch of undefined values. – Cam Nov 23 '22 at 18:21
  • Have you checked suggested solutions here? https://stackoverflow.com/questions/38424517/es5-vs-es6-promises – Nikita Chayka Nov 23 '22 at 18:22

0 Answers0