Hi!
I have an async selector which relies on the return value from another async selector. The values are returned fine, but I get an error in the console saying Uncaught (in promise).
I tried wrapping the selectors with a try..catch, but to no avail.
Example:
const selector1 = selector({
key: "selector-1",
get: async () => {
const response = await.someAsyncAPICall();
return response;
},
});
const selector2 = selector({
key: "selector-2",
get: async ({ get }) => {
const selector1Response = get(selector1);
const response = await.someAsyncAPICallWithParams(selector1Response);
return response;
},
});
const selector3 = selector({
key: "selector-3",
get: async ({ get }) => {
const selector2Response = get(selector2);
const response = await.someAsyncAPICallWithParams(selector2Response);
return response;
},
});
You don't need the async in the 2nd and 3rd selectors (in the code sandbox example). If you remove those it works.
@justintoman well, I do need them if I'm doing some other API calls in those selectors as well. here's an updated sandbox: https://codesandbox.io/s/twilight-sky-ru24z?file=/src/selectors.js
@csantos42 - Something to evaluate with the new selector for the #103 fix.
Any progress?
Any progress?
It hasn't been enabled for the default open source build just yet, but should be shortly. You could test it if you want to tweak nightly yourself. @csantos42 have you had a chance to confirm this issue with that implementation?
Most helpful comment
@justintoman well, I do need them if I'm doing some other API calls in those selectors as well. here's an updated sandbox: https://codesandbox.io/s/twilight-sky-ru24z?file=/src/selectors.js