There isn't much to say about this except that I got rid of nested Promise-s by leveraging async-await 🤷
Refactor proofs module #75
vladimyr/doipjs:refactor-proofs into dev
Looks good to me. I remember when I wrote this a few years ago, the use of async in that particular spot was clashing with some linting rules and thus I resorted to that promise situation.
Glad it's all good now and feels much less clunky.
I never really did like the logic I used to find out whether to make a direct request or proxy request. But that's outside the scope of this PR.
I'm happy with this
@ -194,0 +162,4 @@
try {
return createDefaultRequestPromise(data, opts)
} catch {
return createProxyRequestPromise(data, opts)
If it works: great!
This is the only section of the PR, which I couldn't tell off-hand whether it is equivalent to the previous implementation.
Glad that you called that out cause it is indeed wrong. Won't work without adding await-s:
try {
return await createDefaultRequestPromise(data, opts)
} catch {
return await createProxyRequestPromise(data, opts)
}
But at this point becomes rather ugly and it is probably better to use standard Promise form:
return createDefaultRequestPromise(data, opts)
.catch(() => createProxyRequestPromise(data, opts))
Oh, so await vs. return vs. return await is still valid?
And Jake is still smarter than me and his blog is a treasure trove of useful advice and knowledge!
05f8d9e27e
691d7ee61b
That looks good to me.
691d7ee61b
8e08b2a632
This is outdated and probably needs to be rebased.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Archived
Archived
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?