【发布时间】:2018-05-09 09:33:08
【问题描述】:
我正在从事医疗保健项目,我必须从另一台服务器导入一些医学数据。其他服务器数据是 xml 类型,我想将其转换为 json 以在我的 API 上。
fetch ("http://api.com/rest/api/something&q=")
.then(response => response.text())
.then((response) => {
parseString(responseText, function (err, result) {
console.log(response)
});
}).catch((err) => {
console.log('fetch', err)
})
},
我得到了这个错误:
fetch ReferenceError: parseString is not defined
我正在使用 ReactJs,所以请有人帮我获得将 XML 转换为 JSON 的正确方法吗?
【问题讨论】:
-
这是另一种方法npmjs.com/package/xml-js
-
谢谢,我马上去看看
标签: javascript json xml reactjs