小编Sur*_*thi的帖子

如何解决“尝试获取资源时出现TypeError:NetworkError”。

当我使用aurelia-fetch-client将json数据发布到服务器时,出现此错误“ TypeError:尝试获取资源时出现NetworkError”。我认为您的回答对我非常有用。

  • 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>
    
    Run Code Online (Sandbox Code Playgroud)
  • 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", …
    Run Code Online (Sandbox Code Playgroud)

aurelia-http-client

5
推荐指数
4
解决办法
4万
查看次数

标签 统计

aurelia-http-client ×1