Getting Access is denied while connecting with restful backend in Angular 2 -


i getting following error:

"error: access denied.\r\n\n @ anonymous function (eval code:1343:17)\n @ observable.prototype.subscribe (eval code:52:9)\n @ observable.prototype._subscribe (eval code:109:9)\n @ mapoperator.prototype.call (eval code:54:9)\n @ observable.prototype.subscribe (eval code:52:9)\n @ observable.prototype._subscribe (eval code:109:9)\n @ catchoperator.prototype.call (eval code:29:9)\n @ observable.prototype.subscribe (eval code:52:9)\n @ searchcustomercomponent.prototype.onsearch (eval code:21:9)\n @ _view_searchcustomercomponent0.prototype._handle_ngsubmit_2_0 (function code:232:3)"

here code:

// searchcustomer.component.ts  import { component, oninit } '@angular/core'; import { ngform } '@angular/forms'; import { customeracct } '../models/customer-acct'; import { customerservice } '../services/customer.service';  @component ({     selector: 'search-customer',     templateurl: './app/customer/searchcustomer.component.html'  })  export class searchcustomercomponent {      errormessage: string;     ca: customeracct;     mode = 'observable';     custacctno: number;      constructor (private customerservice: customerservice) {}      onsearch(scf: ngform){          console.log("custacctno = ", this.custacctno);         this.customerservice.getcustomer(this.custacctno).subscribe(             data => this.ca = data,             error => this.errormessage = <any>error);         console.log("this.ca ", this.ca.customeracctid);     }  }     // customer.service.ts import { injectable } '@angular/core'; import { http, response } '@angular/http';  import { observable } 'rxjs/observable'; import { customeracct } '../models/customer-acct';  @injectable() export class customerservice {      constructor (private http: http) {}      private backendurl = 'localhost:8080/bag';      getcustomer(custacct: number): observable<customeracct> {         // let custurl = this.backendurl.concat('customer/findcustomer');         let custurl = 'localhost:8080/bag/customer/findcustomer';         return this.http.get(custurl)                         .map(this.extractdata)                         .catch(this.handleerror);     }      private extractdata(res: response) {         // response object holds data json object, need parse using res.json() method.         let body = res.json();         return body.data || { };     }      private handleerror(error: any) {         // use remort logging infrastructure          let errmsg = (error.message) ? error.message :              error.status ? `${error.status} - ${error.statustext}` : 'server error';             console.error(errmsg);          return observable.throw(errmsg);     } } 
<!-- serachcustomer.component.html --> <div>         <form (ngsubmit)="onsearch(searchcustomer)" #searchcustomer="ngform">                 <div class="col-lg-3">                         <div class="input-group">                                 <input type="text"                                          class="form-control"                                         id="custacctno"                                          placeholder="search customer acct..."                                          [(ngmodel)]="this.custacctno"                                         name="custacctno" required>                                 <span class="input-group-btn">                                         <button class="btn btn-default" type="submit">search</button>                                 </span>                         </div><!-- /input-group -->                 </div><!-- /.col-lg-6 -->         </form> </div> 


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -