油猴 responsejson 转字符串打印输出
你可以使用JSON.stringify()方法将response.json()转换为字符串,然后打印输出,如下所示:
fetch('https://example.com/api/data')
.then(response => response.json())
.then(data => {
const jsonString = JSON.stringify(data);
console.log(jsonString);
})
.catch(error => console.error(error));
请注意,使用console.log()输出字符串可能会导致在控制台中截断较长的字符串,因此你可能需要使用其他方法来显示完整的字符串。
原文地址: https://www.cveoy.top/t/topic/e9HM 著作权归作者所有。请勿转载和采集!