Get JSON data according to URL path

background

The backend interface returns the http://******.json path, and the project needs to use Vue3-based vue-json-viewer@3 to preview JSON data. Therefore, JSON data needs to be obtained through the URL path, and the browser directly accesses the JSON URL to download to the local by default (doesn't work)

Get JSON data via URL as follows:

fetch(jsonUrl)
        .then(response => response.json())
        .then(jsonData => {
    
    
            // jsonData 是对象
            console.log('json数据是:'+jsonData);
        });

Guess you like

Origin blog.csdn.net/weixin_44224921/article/details/128471326