Request header difference beetween get() and load()?

Hi all,

I currently try to interface dhtmlxsuite with postgrest & postgresql
(so no test possible in snippet)

Following code work well :

	var dc_consultant = new dhx.DataCollection();

	dhx.ajax.get("http://192.168.1.127:3000/consultant")
	.then(function (data) {
		dc_consultant.parse(data);
		console.log(JSON.stringify(data));
	})
	.catch(function (err) {
		console.log(err.status);
	});

Following code don’t work :

	var dc_consultant = new dhx.DataCollection();

	dc_consultant.load("http://192.168.1.127:3000/consultant")
	.then(function (data) {
		console.log(JSON.stringify(data));
	})
	.catch(function (err) {
		console.log(err.status);
	});

with the load() function, when looking in network in chrome, the request GET fail in error with “415 (Unsupported Media Type)”
why there is a different result, and why the error is not trapped in my catch() ?

does load function send specific header in the GET ? (i suppose error is in Content-type)

or i miss something ?

best regards

PS : not critical as i have a walkthrough

Please, make sure that your data corresponds to a JSON specification (the most common issue: all the properties names should be quoted):

[{
"id":"15" //will be loaded
}]
[{
id: "15" // will fail
}]

If the issue still occurs for you could you please, provide an example (at least a snippet) of your using dataset

Hi serguey, [UPDATED, snippet was incorrect]

I made 2 snippets (opening temporarly rest for testing)
check rest call in browser before
https://postgrest.echeneis.fr/consultant

(for security i will close it in few days)

This snippet is working
https://snippet.dhtmlx.com/og0bm05d

This snippet is not Working / why ?
https://snippet.dhtmlx.com/q907odke

please look the console, in this case the request GET fail in error with “415 (Unsupported Media Type)”

In case of using the load() method the components expects to see the JSON data, so all the properties and values should be placed in the quotes according to the JSON specification.