There is one thing in your code which may break: (sorry if my english is not good)
Take a look at this code:
functionsomeethingAsync(){returnnewPromise((resolve,reject)=>{setTimeout(()=>{reject()},1000);})}asyncfunctiontest(){constdata=awaitsomeethingAsync();console.log('Will you see me?')console.log(data);console.log('No')}test();
If you run it, you will never see console.log's
And the same is true for you middleware code
If PromiseBasedDataRequest will be rejected then you never reach next() and execution will hang.
Rule of thumb here is simple: when we trying to connect Promise-style and callback-style code and you are somewhere in callback, you should always write .catch() block.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There is one thing in your code which may break: (sorry if my english is not good)
Take a look at this code:
If you run it, you will never see console.log's
And the same is true for you middleware code
If PromiseBasedDataRequest will be rejected then you never reach next() and execution will hang.
Rule of thumb here is simple: when we trying to connect Promise-style and callback-style code and you are somewhere in callback, you should always write .catch() block.