0

I am using angular2 webpack and i want to call local json file using get method but its given me same above error

I tried above solution in my demo cli project its work fine for me but its same in webpack not working

Can any one please help me?

1
  • 2
    What error, and solution, are you referring to? Commented Jul 8, 2017 at 16:04

2 Answers 2

1

Put your file (for example data.json) in the assets directory and then retrieve it using the path `/assets/data.json':

this.http.get('/assets/data.json')
Sign up to request clarification or add additional context in comments.

Comments

0

Thanks Meir

You correct but if we using angular-cli but in webpack its not create assets folder its not work in my case.

But after many R&D i found answer is same like above but need to define that folder inside config details and put json file inside that folder in my case like

config.devServer = {
    contentBase: './src/public',
    historyApiFallback: true,
    quiet: true,
    stats: 'minimal' // none (or false), errors-only, minimal, normal (or true) and verbose
  };

So in my case i need to put json file inside public folder.

Its resolve for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.