-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add customer route #1
Conversation
eaf859a
to
16cd205
Compare
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.
LGTM, but I do have a couple weird questions
@@ -0,0 +1,4 @@ | |||
import config from '../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.
How does JS determine which config to use? Or does this just pass in the contents of all of the .js
and .json
files in the config
folder?
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.
Javascript, when you don't specify a specific js file, defaults to the index.js
file.
The logic for selecting configuration values is here: https://github.com/0time/npcrm-client/blob/master/config/index.js
It basically just starts with default.js
, shoves in the ${process.env.NODE_ENV}
config file, and then overrides with anything in local.json
.
'config.apiServer.basePath', | ||
)}`, | ||
}, | ||
get(context, 'config.defaultAxiosArgs', {}), |
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.
When you pass arguments into query
, do they get placed in this empty object?
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.
On line 17, the empty object is a default parameter if the json path (config.defaultAxiosArgs
) does not exist.
But yeah, this instance
object has default Axios parameters defined by axios.create({...})
, so any calls to query.js
will default with those parameters.
If you pass any other object parameters to the query.js
call, those should override the defaults, assuming axios implemented these features the way I would expect.
src/lib/log-and-return.js
Outdated
@@ -0,0 +1 @@ | |||
export default (content) => console.error(content) || content; |
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'm a little confused by this one. Does this function as an OR using some behavior of console.error
I'm not familiar with, or does it just do both?
edit: The reason I'm confused is because it seems like this would always short circuit, as long as content
isn't a falsey value - in my head, this means you'd always log an error. I did some digging on console.error
and it looks like it'll accept any string input - so is this basically saying the following Ruby-ish pseudocode?
if content.is_a?(String) ? log_error : return(content)
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.
Oh, this is just bad code. I'll fix it.
console.error
, console.log
, etc. return a falsy value (undefined if I recall correctly), so this is just a lazy way of writing to both log and return the content variable.
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.
lgtm 🎉
No description provided.