Im new to javascript and react-native and im trying to build a client which consume oData. By trying of executing jayDatas function initService I got the following error message:
{ message: 'XML DOM parser not supported',
srcText: '',
errorXmlText: '',
request:
{ requestUri: 'https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/$metadata',
method: 'GET',
headers:
{ Authorization: 'Basic Y2dyOjF6M2k3bU05',
Accept: 'application/xml',
'OData-MaxVersion': '4.0' },
recognizeDates: false,
callbackParameterName: '$callback',
formatQueryString: '$format=json',
enableJsonpCallback: false,
async: true },
response:
{ requestUri: 'https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/$metadata',
statusCode: 200,
statusText: undefined,
headers:
[ 'c4c-odata-response-time': '691 ms',
dataserviceversion: '1.0',
'Content-Type': 'application/xml' ],
...
Possible Unhandled Promise Rejection (id: 0):
XML DOM parser not supported`
My Code:
jayData
.initService('https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/', credentials)
.then(function (remoteDB, contextFactory, contexType) {
console.log('HELLO');
});
The error comes from the file jaydata-odatajs\lib\xml.js Line 190 Code:
function xmlParse(text) {
var domParser = undefined;
if (utils.inBrowser()) {
domParser = window.DOMParser && new window.DOMParser();
} else {
domParser = new (require('xmldom').DOMParser)();
}
var dom;
if (!domParser) {
dom = msXmlParse(text);
if (!dom) {
xmlThrowParserError("XML DOM parser not supported0");
}
return dom;
}
Ok i got fixed it. JayData mean we are in browser and try to get the parser out of the window, but there is no parser in window. So I just set in window the DOMParser and it works.
Thanks!