title: angular2 http.post() to local json file
body: <p>little help?</p>
  
  <p>I am trying to <strong>write pure JSON</strong> to a file <strong>inside</strong> my project, my project tree looks like this:</p>
  
  <pre><code>src
  -&gt;app
  --&gt;components
  ---&gt;people.component.ts
  ---&gt;(other irrelevant components)
  --&gt;services
  ---&gt;people.service.ts
  --&gt;data
  ---&gt;JSON.json
  -&gt;(other irrelevant src files)
  </code></pre>
  
  <p>The code in my <code>people.component.ts</code> is just used to <strong>call and subscribe</strong> to a function inside my <code>people.service.ts</code>, passing the <code>newPerson</code> property which is data-binded from the DOM using angular2 magic; this is the function inside <code>name.service.ts</code>:</p>
  
  <pre><code>public addPerson(newPerson) {
          let headers = new Headers();
          headers.append('Content-Type', 'application/json');
          return this.http.post('app/data/PEOPLE.json', newPerson, { header: headers })
          .map(res =&gt; res.json())
  }
  </code></pre>
  
  <p>My objective is to write (if necessary replace) the <code>newPerson</code> property (or the entire file) inside <code>PEOPLE.json</code>. of course, the current <code>addPerson()</code> function returns an error.</p>
  
  <p>I've also tried the <code>put</code> method, it errors slightly differently, but i haven't found solutions to either method.</p>
  
  <p>I know categorically it's not an error with the format/type of data i'm trying to put in <code>PEOPLE.json</code> file.</p>