crossDomain: true,
{"Access-Control-Allow-Origin": "*"},
{"Access-Control-Allow-Credentials": "true"},
{"Access-Control-Allow-Methods": "GET,HEAD,OPTIONS,POST,PUT"},
{"Access-Control-Allow-Headers": "Access-Control-Allow-Headers," +
"Origin,Accept, " +
"X-Requested-With," +
"Content-Type," +
"Access-Control-Request-Method, " +
"Access-Control-Request-Headers"}]CORS_ORIGIN_ALLOW_ALL = True # allowed IP to make request
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_METHODS = default_methods
CORS_ALLOW_HEADERS = default_headers
const SERVICE_URI: string = 'http://127.0.0.1:8000/entity/';
new DataManager({
url: SERVICE_URI,
adaptor: new UrlAdaptor,
headers: [
{"Authorization": "Token ea53edb70b0d7db7e8afe4e67f1071158705d0fa"},
{"Content-Type": "application/json; charset=utf-8"},
]
}).executeQuery(new Query()).then((e) => {
console.log(e.data);
});
|
import { Query, DataManager, ODataAdaptor, UrlAdaptor } from '@syncfusion/ej2-data';
//create customAdaptor from UrlAdaptor (extend method and properties)
class CustomAdaptor extends UrlAdaptor {
public processResponse(data: any, ds: any, query: any, xhr: any, request: any, changes: any): Object {
request.data = '{}';
//calling base class processResponse function
let original: any = super.processResponse.apply(this, arguments);
return original;
}
}
let adaptor: any = new CustomAdaptor();
adaptor.options.requestType = null; //overwrite the default requestType to GET from POST
CustomAdaptor.prototype.convertToQueryString = ODataAdaptor.prototype.convertToQueryString;
let db: any = new DataManager({
url: 'Home/dataSource',
adaptor: adaptor//assign the custom adaptor
}) |