我想做的显示数据内的网址对我的节点站出来,但它显示没有,有一些我做错了我的代码
const extractRefDefaultSchema = async (data) => {
const url = "https://mos.esante.gouv.fr/NOS/TRE_R81-Civilite/FHIR/TRE-R81-Civilite/TRE_R81-Civilite-FHIR.json"
https.get(url,(res) => {
let body = "";
res.on("data", (chunk) => {
body += chunk;
});
res.on("end", () => {
try {
let json = JSON.parse(body);
// do something with JSON
} catch (error) {
console.error(error.message);
};
});
}).on("error", (error) => {
console.error(error.message);
});
console.log("extractRefDefaultSchema");
};
2条答案
按热度按时间icomxhvb1#
您可以使用fetch API来执行以下操作:
e0bqpujr2#
你可以用axios实现同样的功能,它会简单得多。
代码: