我在angularjs5中有这个错误,
src / app / search / job.search.ts(17,10):错误TS2554:预期2-3个参数,但得到1。 src / app / search / job.search.ts(21,10):错误TS2554:预期2-3个参数,但得到1。
这是我的代码:
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class JobSearch{
constructor(private _http: Http){}
private _jobListUrl = 'https://api.shiftjobapp.com/api/v3/job_list?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIzMjQsImlzcyI6Imh0dHA6XC9cL2FwaS5zaGlmdGpvYmFwcC5jb21cL2FwaVwvdjNcL2F1dGhlbnRpY2F0ZV9qb2Jfc2Vla2VyIiwiaWF0IjoxNTEyMzY3OTg1LCJleHAiOjE1MTMyMzE5ODUsIm5iZiI6MTUxMjM2Nzk4NSwianRpIjoiMWQ4NmZkZDYzZDI3YmFiODE0NjA5OTRjOGZhYjI4NTUifQ.3EzNsu154q7a6xFuhQSakBlC-rj1D0HZqLiuwHblNao';
private _jobDetailsUrl = 'https://api.shiftjobapp.com/api/v3/job_detailed?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIzMjQsImlzcyI6Imh0dHA6XC9cL2FwaS5zaGlmdGpvYmFwcC5jb21cL2FwaVwvdjNcL2F1dGhlbnRpY2F0ZV9qb2Jfc2Vla2VyIiwiaWF0IjoxNTEyMzY3OTg1LCJleHAiOjE1MTMyMzE5ODUsIm5iZiI6MTUxMjM2Nzk4NSwianRpIjoiMWQ4NmZkZDYzZDI3YmFiODE0NjA5OTRjOGZhYjI4NTUifQ.3EzNsu154q7a6xFuhQSakBlC-rj1D0HZqLiuwHblNao';
getJobs(){
return this._http.post(this._jobListUrl)
.map((response:Response) => response.json());
}
getJobDetails(){
return this._http.post(this._jobDetailsUrl)
.map((response:Response) => response.json());
}
}
答案 0 :(得分:1)
POST
请求需要数据
参见例如
addHero (hero: Hero): Observable<Hero> {
return this.http.post<Hero>(this.heroesUrl, hero, httpOptions).pipe(
tap((hero: Hero) => this.log(`added hero w/ id=${hero.id}`)),
catchError(this.handleError<Hero>('addHero'))
);
}