Angular2 appear warning XMLHttpRequest at chrome

ساخت وبلاگ

Vote count: 0

I used Http Restful API at Angular2, but appear the following warning message.

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

Please tell me how to do that.


http_restful_service.ts
import { Injectable } from '@angular/core';
import { Http, Headers, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class HTTPRestfulService { constructor(private _http: Http) {} getAllProjectName() { var headers = new Headers(); headers.append('Content-Type','charset=uft-8'); return this._http.get('http://localhost/api/database/', {headers: headers}) .map(res => res.json()); }
}

backstage_view.component.ts

import { Component, OnInit } from '@angular/core';
import { HTTPRestfulService } from './../../../service/http_restful_service';
@Component({ moduleId: module.id, selector: 'backstage_view', templateUrl: './backstage_view.component.html', styleUrls: ['./backstage_view.component.css']
})
export class BackstageViewComponent implements OnInit { allProjects: string; constructor(private _restfulapi: HTTPRestfulService) {} ngOnInit() { this._restfulapi.getAllProjectName() .subscribe( data => this.allProjects = data, error => console.log(error), ); }
}
asked 38 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 420 تاريخ : دوشنبه 30 اسفند 1395 ساعت: 12:53