我正在尝试提出我的第一个HTTP POST请求。我的GET请求工作正常(在同一服务中),但是当我尝试发出POST请求时却出现了错误
错误TypeError:无法读取ApiService.push ../ src / app / services / api.service.ts.ApiService.getTracsStartEvents(api.service.ts:57)上未定义的属性“ post”
我在同一文件中以与使用GET请求相同的方式使用它。我不明白为什么POST请求无法正常工作。我必须在语法上犯一些错误。谁能指出我正确的方向?
这是我称为post函数的位置(这是从另一个获取位置更新的服务中获得的):
import { Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { GeoJson } from '../shared/geo-json';
@Injectable({
providedIn: 'root'
})
export class PositionUpdateService {
positionUpdate: GeoJson;
constructor(private apiService: ApiService,
) {
this.positionUpdate = new GeoJson( 'Feature',
{type: 'Point', coordinates: [-121.0, 37.5, 1000]} );
//console.log('posUpdate: this.positionUpdate: ', this.positionUpdate );
}
getMissionStartEvents( devices ) {
console.log('posUpdate svc, getMissionStartevents, imeis: ', devices);
const events = this.apiService.getTracsStartEvents( devices );
console.log(events);
}
}
一切从我的地方开始HomeComponent:
export class HomeComponent implements OnInit, OnChanges {
constructor(public appSettingsService: AppSettingsService,
public layerControlDialogComponent: MatDialog,
private devicesToTrackService: DevicesToTrackService,
private positionUpdateService: PositionUpdateService,
private httpClient: HttpClient) { }
startTracking(devices) {
console.log('going to start tracking ', devices);
this.positionUpdateService.getMissionStartEvents(devices)
}
拉莫斯之舞
相关分类