My app.vue
<template>
<div id="app">
<h1>{{ titulo }}</h1>
<li v-for="usuario of usuarios">
</li>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
},
created() {
//componente
let promisse = this.$http.get('http://swapi.co/api/planets/1/', { headers: { 'Access-Control-Allow-Origin': '*' }});
console.log(promisse);
promisse.then(res => alert(res));
}
}
</script>
My main.js
import Vue from 'vue'
import App from './App.vue'
//importando o vue-rsource
import VueResource from 'vue-resource';
//Usando globalmente o vue-resource
Vue.use(VueResource);
new Vue({
el: '#app',
render: h => h(App)
})
You're giving this error
XMLHttpRequest can not load link . Request Access-Control-Allow-Origin header field is not allowed by Access-Control-Allow-Headers in preflight response. localhost /: 1 Uncaught (in promise) Response {url: " link ", ok: false, status: 0, statusText: "", headers: Headers, ...}