Я заметил, что следующий код не компилируется (параметры передаются как переменная httpOptions
)
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
withCredentials: true,
observe: 'response'
};
return this.http.post(this.SIGNIN_USER_URL, body, httpOptions); // options is passed as a variable `httpOptions`
Я получаю следующую ошибку
Argument of type '{
headers: HttpHeaders;
observe: string;
responseType: string;
}' is not assignable to parameter of type'{
headers?: HttpHeaders;
observe?: "body";
params?: HttpParams; reportProgress?: boolean;
respons...'.
Types of property 'observe' are incompatible.
Type 'string' is not assignable to type '"body"'.'
Но следующий код делает (параметры передаются как буквальный объект)
return this.http.post(this.SIGNIN_USER_URL, body, {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
withCredentials: true,
observe: 'response'
})
Почему?