---
# System prepended metadata

title: Reading env vars

---

# Reading env vars

Write a method to read configuration values from a configuration object based on a key

Example of keys as input: 
"profile.setting.showImage"
"home.showAnalytics"

```typescript
//code


const config = {
    profile: {
        setting: {
            showImage: true
        }
    }
};

const showImageVal = (key: string) => {
    const keyArr = key.split('.');
    let finalValue;
    keyArr.forEach(key => {
        finalValue = config[key];
    })
}

```