xyz-data / json

Gildata organizations JSON Datas!
MIT License
1 stars 0 forks source link

CORS #2

Open xyzdata opened 7 years ago

xyzdata commented 7 years ago

CORS

https://github.com/xyz-data/json/blob/master/cors.js


fetch('https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest',{
    method: 'get',
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'X-Api-Key': `0987b00e542141369049e647701b65d9`
    }
})
.then(function(response) {
    return response.json()
}).then(function(json) {
    console.log('parsed json: ', json)
}).catch(function(error) {
    console.log('parsing failed: ', error)
});

// https://gist.github.com/xgqfrms-GitHub/a3fcffb6d7923e2a7471041053f00162
xyzdata commented 7 years ago

https://github.com/xyz-data/json/blob/master/cors.js