第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

可觀察錯(cuò)誤,嘗試使用get方法

可觀察錯(cuò)誤,嘗試使用get方法

眼眸繁星 2021-10-21 17:18:31
我正在嘗試重構(gòu)自定義 api get,如下所示: get( route: string, responseType: RespType = 'json', fullResponse: boolean = false, params = null): Observable<any> {    return this.invoke( 'GET', route, null, responseType, fullResponse, true, params);  }對(duì)此:@Injectable({  providedIn: 'root'})export class DocumentCorrespondenceService {  allCorrespondence: Observable<DossierEntry>;  correspondenceEntries: Observable <DossierEntry>;  attachmentEntries: Observable<DossierEntry>;constructor(private http: HttpClient) { }getDossierEntry( type: String = '' ): Observable<Array<DossierEntry>> {  const entryType = type === '' ? 'all' : 'type/' + type;  return this.http.get( '/api/patient/{patientUUID}/DossierEntry/' + entryType );}getDossierEntryFileData( entryID: number ): Observable<HttpResponse<Blob>> {  return this.get( '/api/patient/{patientUUID}/DossierEntry/' + entryID + '/fileData', 'pdf', true );}}但我現(xiàn)在收到這樣的錯(cuò)誤:Type 'Observable<Object>' is not assignable to type 'Observable<DossierEntry[]>'.  The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?    Type 'Object' is missing the following properties from type 'DossierEntry[]': length, pop, push, concat, and 26 more.ts(2322)那我必須改變什么?
查看完整描述

1 回答

?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

在新的 Angular 版本中(導(dǎo)致升級(jí) typescript 版本),您必須指定 http 調(diào)用預(yù)期的類(lèi)型:


getDossierEntry( type: String = '' ): Observable<DossierEntry[]> {

  const entryType = type === '' ? 'all' : 'type/' + type;

  return this.http.get<DossierEntry[]>( '/api/patient/{patientUUID}/DossierEntry/' + entryType );

}

注意:我還用 改變了你的Array類(lèi)型[],這更像是“javascript”


查看完整回答
反對(duì) 回復(fù) 2021-10-21
  • 1 回答
  • 0 關(guān)注
  • 206 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)