This is a migrated thread and some comments may be shown as answers.

transform JSONP to get ?

1 Answer 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
LEO
Top achievements
Rank 1
Veteran
LEO asked on 09 Aug 2020, 10:24 AM

Hello,

 

my server support CORS so I want to use get instead of jsonp when fetching data using the action on a model ? can someone help me please ? Thanks

private fetch(action: string = '', data?: any): Observable<any[]> {
        return this.http
            .jsonp(`https://demos.telerik.com/kendo-ui/service/Products/${action}?${this.serializeModels(data)}`, 'callback')
            .pipe(map(res => <any[]>res));
    }

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 11 Aug 2020, 02:10 PM

Hi LEO,

All Kendo UI for Angular components are simply representational ones. Thus they will function as expected as long as the data passed to them is in a supported format. That being said, the request used to get the remote data is of no relevance to the components. Thus it is in the hands of the developer to use the required remote request in order to get the respectful data. It can be a GET, POST, JSONP or any other request type. If you check the "asynchronous source" option from the following example:

https://www.telerik.com/kendo-angular-ui/components/grid/data-binding/

you will see that there is a GET request used to fetch the data. Please check the nothwind.service.ts file:

    protected fetch(tableName: string, state: any): Observable<GridDataResult> {
        const queryStr = `${toODataString(state)}&$count=true`;
        this.loading = true;

        return this.http
            .get(`${this.BASE_URL}${tableName}?${queryStr}`)
            .pipe(
                map(response => (<GridDataResult>{
                    data: response['value'],
                    total: parseInt(response['@odata.count'], 10)
                })),
                tap(() => this.loading = false)
            );
    }
}

I hope the provided information helps you to move forward with this case.

Regards,
Svetlin
Progress Telerik

Tags
Grid
Asked by
LEO
Top achievements
Rank 1
Veteran
Answers by
Svet
Telerik team
Share this question
or