Refactor and destructure resData after performing fetch API calls
Closed this issue · 1 comments
TheYuriG commented
resData is a massive object parsed by res.json()
. To pull anything from it, a lot of property drilling is required. Destructure those properties for better code clarity.
In most lines, we can replace
.then((resData) => {
for
.then(({errors, data: {graphQL-resolver: {all-properties}}}) => {
and then only replace graphQL-resolver
with whatever query/mutation we are actually calling for and then all-properties
for the individual properties we need. Obviously, we also need to update those properties in this,setState
.
This issue is merely for readability improvement and offers no function processing performance upgrades.