あなたが使用している場合はHttpClientをHTTPではなく、あなたのコードすべきは、このようになります:あなたのparamsがオプションの場合
login(credintials: Authenticate): Observable<any> {
const body = {
username: credintials.username,
password: credintials.password,
grant_type: 'password',
client_id: credintials.client_id
};
const headers = new HttpHeaders()
.set('Content-Type', 'application/x-www-form-urlencoded')
.set('Authorization', 'Basic loremlorem');
return this.http.post(`${baseUrl}/uaa/oauth/token`,
body,
{
headers: headers
}
);
}
次のようなパラメータを追加する必要があります。
let params: HttpParams = new HttpParams();
if (param) {
params = params.append('page', param.page);
}
ソースコードのようになります。
/**
* Construct a new body with an appended value for the given parameter name.
*/
append(param: string, value: string): HttpParams;
チェック[この](https://stackoverflow.com/a/41133924/2545680) –
@Maximusだけしようと、それは動作しません。 :/ –
私は私の答えに例を提供してくれました。それは私のために働きました、私は角度v4.xを使用しています –