When I use aurelia-fetch-client to post json data to server and I got this error "TypeError: NetworkError when attempting to fetch resource." I think your answer is very useful to me.
post.html
<template> <section> <form role="form" submit.trigger="signup()"> <div class="form-group"> <label for="OrganisationId">OrganisationId</label> <input type="text" value.bind="organisationId" placeholder="OrganisationId"> </div> <div > <label for="OrganisationName">OrganisationName</label> <input type="OrganisationName" value.bind="organisationName" placeholder="Password"> </div> <button type="submit" class="btn btn-default">Enter</button> </form> </section> </template>
post.js
import 'fetch'; import { HttpClient, json } from 'aurelia-fetch-client'; let httpClient = new HttpClient(); export class signup { heading1 = "Welome to User"; organisationId = ""; organisationName = ""; signup() { alert("calliong"); var myUser1 = { organisationId: this.organisationId, organisationName: this.organisationName } console.log(myUser1); httpClient.fetch('http://172.16.0.26:8085/employee-management/rest/employees/addOrganisations', { method: "POST", body: JSON.stringify(myUser1) }) .then(response => response.json()) .then(data => { console.log(data); }); } }