누군가가 http 응답에서 각도 5로 번호를 가져 오는 것을 도와 줄 수 있습니까? 나는 지금 그것을하는 방법을하지 않는다, 나는 인터넷에서 검색하고 있었다. 그러나 Angular는 그렇게 빨리 성장한다. 그래서 그것은 나를 도와주지 않는다. 어떤 도움을 주셔서 감사합니다!http에서 각도 번호를 가져 오는
내 코드 :
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { User } from '../entities/User';
@Injectable()
export class UserService {
private usersurl: 'http://localhost:8080/api/users';
user: User;
id: number;
constructor(private http: HttpClient) {}
isLoggedIn() {
return this.user != null;
}
isAdmin() {
return this.user.isAdmin;
}
unLoggin() {
this.user = null;
}
login(username: string, password: string) {
this.id = null;
this.http.get<number>(`${this.usersurl}/verify?username=${username}&password=${password}`).subscribe(id => this.id = id);
alert(this.id);
if (this.id != null) {
return true;
} else {
return false;
}
}
}
이 경고 [개체 개체] 로컬 호스트 : 8080/API/사용자/사용자가 HTTP 요청을하는 경우에는 JSON이
"숫자"를 얻는 것은 무엇을 의미합니까? – KHAN
문자열이 아닌 숫자 형식으로 데이터를 원합니 까? json 형식뿐만 아니라 일부 코드를 넣을 수 있습니까? –
@KHAN - API 서버는 일반 숫자 exa를 반환합니다. 2 –