'Promise' is not defined no-undef

358 Views Asked by At

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}
0

There are 0 best solutions below