Vue axios jsonp

because axios no longer supports jsonp, I installed the jsonp module, npm i jsonp-- save,
in the way of netizens, and then introduced import jsonp from "jsonp"
in one component. I want to request the link address of another website http://rrrrrrk.tech/data.json

.

the code is as follows:

 methods:{
          getList: function () {
             jsonp("http://rrrrrrk.tech/data.json", null, (err, data) => {
                debugger
               if (err) {
                 console.error(err.message);
               } else {
                 if (data.list.length > 0) {
                   data.list.map((item) => this.list.push(item))
                   console.log(data);
                 }
               }
             })
            }
        },
        created:function(){
          this.getList()    
        } 

the problem now is that the code did not enter the debugger,console and an error was reported. The error is as follows:


I would like to ask if there is something wrong with my code or this link? Why not all external links can be requested? Which god provides an address that can achieve jsonp effect,

May.13,2021

here you need to understand the principle of JSONP, which actually executes the content returned by the interface as javascript, usually by wrapping the returned data with the specified callback function.
for example: request www.example.com/a?callback= "callbackFn"
API return: "callbackFn (" + jsondata + ")"


what misunderstandings may you have about jsonp
jsonp the return value must be a callback function js code is not json data

your json file is matched with Access-Control-Allow-Origin: * , you can get

directly.
axios.get('http://rrrrrrk.tech/data.json').then(function(res){
    console.log(res)
})
Menu