2017-12-03 8 views
0

私はAngular 4で以下のサービスを提供しています。私のサーバに情報を投稿しようとすると、 "http://localhost:4200"が私のリクエストに適用され、結果は "http://localhost:4200/localhost:5000/login"です。どのように私はこれを解決できますか?投稿リクエストからベースURLを削除する

import { Injectable } from '@angular/core'; 
import { HttpClient, HttpHeaders } from '@angular/common/http'; 


@Injectable() 
export class AuthService { 

    constructor(private http: HttpClient) { } 

    public authFunc(payload) { 
    const headers = new HttpHeaders(); 
    headers.set('Content-Type', 'application/json'); 
    console.log(this.http.post); 

    return this.http.post("http:/localhost:5000/login", payload, {headers: headers}); 
    } 
} 
+0

あなたは '/'を見逃しました。これは 'http://'でなければなりません。 –

+0

それは間違いでした。どうもありがとうございました!!! –

答えて

0

return this.http.post("/login", payload, {headers: headers});

編集:あなたはポート5000上で動作するWebサーバーを持っていますか?

関連する問題