1

In my assets i've got a config.json file with an apiUrl

{
    "apiUrl":"https://api.example.com"
}

I've got multiple environments, but one of them needs to be able to be altered after the build.

import * as config from '../assets/config.json';

export const environment = {
    production: true,
    appTheme: "blue-theme",
    apiUrl: config.apiUrl
    appName: "App",
};

in my typings.d.ts i've got

declare module "*.json" {
    const value: any;
    export default value;
}

When i do console.log(config) I get:

{
    apiUrl:"https://api.example.com"
}

But when i do console.log(config.apiUrl) I get:

undefined

Can someone tel me what i'm doing wrong?

1

1 Answer 1

1

How to retrieve Json data

using by node

const config: any = require('../assets/config.json');
export const environment = {
    production: true,
    appTheme: "blue-theme",
    apiUrl: config.apiUrl
    appName: "App",
};

Using by http

How to extract JSON data from http.get in Angular 2 properly?

How to fetch JSON file in Angular 2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.