New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update API/generate, add Russian #733
Conversation
Also added Russian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @qm3ster
Could you look at my comments please?
}) | ||
} | ||
routes: () => | ||
axios.get('https://my-api/users').then(res => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return statement missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What, where?
'/users/2', | ||
'/users/3' | ||
] | ||
routes: ['/users/1', '/users/2', '/users/3'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this makes it clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was Prettier that did this, actually. Seemed more than short enough not to split.
I split the french because it uses /utilisateurs/
instead of /users/
which imo is a bit much. Maybe the examples should be monolingual, so that if we later have a translation build process they can be imported from one place.
if (payload) return { user: payload } | ||
else return { user: await backend.fetchUser(params.id) } | ||
} | ||
asyncData: async ({ params, error, payload }) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it might be optimised, I don't think it's a good idea for documentation since it makes it harder to read for a human :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I like to think that it's more clear that the function doesn't rely on
this
when it's an arrow. - If I put it as method syntax, I'd have to have a return statement, which dilutes the actual logic of the 2 paths.
- Clearly, I am sane and even conservative, since I had the sense to see the current solution is more readable to a novice dev than:
asyncData: async ({ params, error, payload }) => ({ user: payload || (await backend.fetchUser(params.id)) })
and stopped at that.
That said, I'm open to change this and go through all the files substituting it, just tell me which specific operator you dislike here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like @manniL opinion on this particular comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manniL it has come a full circle UwU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for something like
async asyncData ({ params, error, payload }) {
if (payload) {
return { user: payload }
}
const user = await backend.fetchUser(params.id)
return { user }
}
Not all readers know ES6 and short circuits very well, so I'd favor a "more readable" /simple version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oke, will do.
How do you feel about the original version:
async asyncData ({ params, error, payload }) {
if (payload) return { user: payload }
else return { user: await backend.fetchUser(params.id) }
}
i'd just change it to arrow notation since this
isn't in use, and remove the unnecessary else
asyncData: async ({ params, error, payload }) => {
if (payload) return { user: payload }
return { user: await backend.fetchUser(params.id) }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qm3ster I don't like "inline ifs" actually. Was a fan of them years ago but now I appreciate the extra braces for readability.
This is also aligns with our eslint config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, will do like yours. Should the await
also be on a separate line?
whispers: multiline ifs are a code smell, pull them out into a named function
@Atinux I replied to the comments, tell me what to do please :) |
cc @Atinux |
.then((res) => { | ||
var routes = res.data.map((user) => { | ||
return '/users/' + user.id | ||
routes: callback => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually @manniL I now see that this may be confusing, because it does call the callback, but also returns a Promise
which resolves after the callback returns.
Would putting void axios.get
be too arcane?
Should I just put the statement of the routes
function into a {}
block so that it returns undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to keep a callback example for the routes function at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine by me. 😩 👌
So I nuke it?
From all languages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say so
No description provided.