little help?
I am trying to write pure JSON to a file inside my project, my project tree looks like this:
src
->app
-->components
--->people.component.ts
--->(other irrelevant components)
-->services
--->people.service.ts
-->data
--->JSON.json
->(other irrelevant src files)
The code in my people.component.ts
is just used to call and subscribe to a function inside my people.service.ts
, passing the newPerson
property which is data-binded from the DOM using angular2 magic; this is the function inside name.service.ts
:
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 => res.json())
}
My objective is to write (if necessary replace) the newPerson
property (or the entire file) inside PEOPLE.json
. of course, the current addPerson()
function returns an error.
I've also tried the put
method, it errors slightly differently, but i haven't found solutions to either method.
I know categorically it's not an error with the format/type of data i'm trying to put in PEOPLE.json
file.