[Vuejs]-Http get vue.js + node.js returns empty data

0👍

res.end() is intended for ending the response without data (see https://expressjs.com/en/api.html).

If you want to return json, the easiest way is to use res.json():

app.get('/sources', function (req, res) {
    res.set({
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET'
    });
    let data = getNews.getSources()
    res.json(data);
});

0👍

I found the problem, it’s a security thing with ios, they don’t allow http calls, only https (I run the project on an ios emulator)

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

Leave a comment