我有点担心,如果有人可以帮到我,我会使用laravel 5.8 API创建,当我从posteman的walk检索参数数据mtr时,但是当我使用此url执行相同的操作时,我<
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Candidate } from '../models/candidate';
@Component({
selector: 'app-candidate',
templateUrl: './candidate.page.html',
styleUrls: ['./candidate.page.scss'],
})
export class CandidatePage implements OnInit {
mtr: '45';
// tslint:disable-next-line: new-parens
data: any;
url = 'http://127.0.0.1:8000/api/studentbyid/';
constructor( private httpClient: HttpClient) { }
ionViewWillEnter(mtr: string) {
return this.httpClient.get(this.url + '/' + this.mtr)
.subscribe(
data => {
this.data = JSON.stringify(data);
console.log(this.data);
},
error => {
console.log(error);
});
}
ngOnInit() {}
getbyID( mtr: string) {}
}
这是我直接放置在控制台中的结果 enter image description here 这就是我尝试从用户那里检索单词的时候enter image description here
如果有人可以帮助我,而我注意到没有对象形式的答案