Skip to content

Commit

Permalink
Updated getConfig and Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Robsahm committed Jan 16, 2017
1 parent 395946a commit f84aa17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
Initiate config fetching. `environment` is one of "dev", "stage" or "prod"
```
var configClient = require("next-config-client");
configClient({
configClient.initializeConfigUpdate({
requestUrl: "ws://example.com/api/vx/config/",
environment: "dev"
})
.then((config) => {
// Do stuff with config and start app
});
```
After that use `configClient.config` to get the latest config
After that use `configClient.getConfig(["part", "key"], defaultValue)` to get the config value you need.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const initializeConfigUpdate = (conf) => {
return new Promise(connect);
};

const getConfig = ([part, key], def) => {
const confValue = R.path(part + '.' + key, config)
const getConfig = (path, def) => {
const confValue = R.path(path, config);
if (confValue !== undefined) {
return confValue;
}
Expand Down

0 comments on commit f84aa17

Please sign in to comment.