PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] How can I get rid of RequestOptionsArgs in the below code

 April 14, 2022     angular, javascript, migration     No comments   

Issue

I am migrating my project from angular 7 to 8. I replaced Http with HttpClient but am stuck in the below code. How should I get rid of RequestOptionsArgs.

data-lang="js" data-hide="false" data-console="true" data-babel="false">
import { HttpClient } from '@angular/common/http';
import { RequestOptionsArgs } from '@angular/http/src/interfaces';
import { Observable } from 'rxjs';
import { LocalDataSource } from '../local/local.data-source';
import { ServerSourceConf } from './server-source.conf';
import 'rxjs/add/operator/toPromise';
export declare class ServerDataSource extends LocalDataSource {
    protected http: HttpClient;
    protected conf: ServerSourceConf;
    protected lastRequestCount: number;
    constructor(http: HttpClient, conf?: ServerSourceConf | {});
    count(): number;
    getElements(): Promise<any>;
    /**
     * Extracts array of data from server response
     * @param res
     * @returns {any}
     */
    protected extractDataFromResponse(res: any): Array<any>;
    /**
     * Extracts total rows count from the server response
     * Looks for the count in the heders first, then in the response body
     * @param res
     * @returns {any}
     */
    protected extractTotalFromResponse(res: any): number;
    protected requestElements(): Observable<any>;
    protected createRequestOptions(): RequestOptionsArgs;
    protected addSortRequestOptions(requestOptions: RequestOptionsArgs): RequestOptionsArgs;
    protected addFilterRequestOptions(requestOptions: RequestOptionsArgs): RequestOptionsArgs;
    protected addPagerRequestOptions(requestOptions: RequestOptionsArgs): RequestOptionsArgs;
}

This file location is ../node_modules/ng2-smart-table/lib/data-source/server/server.data-source.d.ts


Solution

You can create your own interfaces and change the imports to your own interface, but there will be some changes. your interface will look like :-

export interface RequestOptionsArgs { 
  url?: string|null;
  method?: string;
  search?: string|{[key: string]: any | any[]}|null;
  params?: string|{[key: string]: any | any[]}|null;
  headers?: HttpHeaders|null;
  body?: any;
  withCredentials?: boolean|null;
  responseType?: 'arraybuffer'|'blob'|'text'|'json';
}

then you can change your implementation as per these parameters and map these to httpclient.



Answered By - Aakash Garg
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing