1
get requestを使用してローカルAPIサーバからjsonデータを取得しようとしています。私はいつもこのエラーを受け取ります。私はすでに多くのサイトを訪れていますが、私はこの問題の解決策を見出していません。 なぜ誰かがそれを修正する方法を知っていますか?より多くの設定情報が必要な場合は、お知らせください。このリソースにアクセスするには401フル認証が必要です
import {Injectable} from 'angular2/core';
import {Http} from "angular2/http";
import 'rxjs/add/operator/map';
import 'rxjs/Rx';
import {Headers} from "angular2/http";
import {Jsonp} from "angular2/http";
@Injectable()
export class HTTPTestService{
constructor(private _http: Http){}
getCurrentTime(){
console.log('je suis le test0');
console.log(this._http.get('http://localhost:9090/webservices/pivot/rest/v1/cube/discovery').map(res => res.json()));
console.log('je suis le test10');
return this._http.get('http://localhost:9090/webservices/pivot/rest/v1/cube/discovery')
.map(res => res.json());
}
postJSON(){
var json=JSON.stringify({var1: 'test', var2: 3});
var params = 'json=' + json;
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
return this._http.post('http://jsonplaceholder.typicode.com/posts',
params,{
headers: headers
})
.map(res => res.json());
}
}