6
votes
Accepted
Take postcodes and get the Lat long information from them
The code could be improved with a few tweaks, but it's not bad, and the overall structure looks just fine to me.
Error handling is in the wrong place Some of your route handler are ...
5
votes
Take postcodes and get the Lat long information from them
Test case structure
It doesn't seem like the code totally "lacked effort and structure" but the structure, at least of the test cases, could be better. Since all three ...
4
votes
Accepted
How do I refactor this fetch request?
Let me share my async await solution for that:
Because Your fetch function is pretty similar till the res.text(), I would ...
4
votes
Accepted
Display and search through a JSON's items in Vue.js
Overall the code looks fine. There aren't any drastic changes I would advise - just mostly a few simplifications. As far as the design goes it looks good, though it may be wise to add a spinner icon ...
3
votes
Accepted
A React - Typescript custom hook for any request (GET, POST, PUT, DELETE) to my back end
The biggest part is that the code works and it looks okay.
I only have a few concerns about unnecessary rerenders and inconsistent UI because of inaccurate status state.
Below are a few minor things I'...
2
votes
Accepted
Disabling a form button while there's an http request running
Yes, your approach looks correct to me. I also had faced similar issues earlier in my project (before hooks were introduced) and had used setState for a boolean variable to enable and disable the ...
2
votes
Accepted
Try-catch-finally snippet
Refactoring to DRY Code
In order to avoid repetition, we could create a couple of reusable functions to enable your functions to all use the same pattern.
The pattern:
start loading
await operation
...
2
votes
Idomatic way to ignore `finally` block after cancelling network request
Ignore the warning. React gives a warning when you setState after
unmount because it indicates a memory leak (in this case, the
lingering network request, if not canceled). If the network request
...
1
vote
Upload multiple images using react and axios
Given that there are a lot of files (5,000), I'd certainly recommend batching the upload process for many reasons; user experience being one of them.
With the help of ...
1
vote
How to deal with nested callbacks in a clean way?
You can use the async/await syntax, its purpose is exactly cleaning up nested callbacks like this.
1
vote
Accepted
JavaScript that deletes everything inside a folder on Box.com
Am I using async/await properly and following best practices?
Given how you responded to your own question #1 (i.e. "A: ...
1
vote
Accepted
Access token regeneration for Axios requests
General Thoughts
I haven't used the paypal API before but did obtain credentials and ran the code. I don't see much that would improve the logic to fetch the token but do see small improvements that ...
1
vote
Getting data from API every x seconds and store it in a database
Quickly overviewing the code - it would work.
If you are into a more readable approach, I may have just a few (minor) comments:
Declare fetchItems as ...
1
vote
multiple api calls through promise
First of all, putting all your code in the props of your JSX is making it unreadable. Extract this into a function, and have your JSX reference that instead.
Next, for debugging, I would recommend ...
1
vote
Accepted
Idomatic way to ignore `finally` block after cancelling network request
Finally only for unconditional execution
I am not a React user, and as such I may be missing something unique to the React way.
It seams very strange that you use a ...
1
vote
Cancelling ongoing http requests when next one is started - web app search feature
You can rewritte this piece of code:
...
1
vote
Fetching data from API in JavaScript
It can be done in many ways based on your use case & code structure, but i feel this can be optimal way of structuring.
api/services/index.js
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
axios × 20javascript × 17
react.js × 9
node.js × 6
ecmascript-6 × 3
express.js × 3
api × 2
typescript × 2
async-await × 2
vue.js × 2
redux × 2
beginner × 1
html × 1
css × 1
interview-questions × 1
image × 1
error-handling × 1
database × 1
asynchronous × 1
generics × 1
cache × 1
promise × 1
user-interface × 1
twitter-bootstrap × 1
network-file-transfer × 1