0
My app.See
<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 making that mistake
Xmlhttprequest cannot load http://swapi.co/api/planets/1/. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight Response. localhost/:1 Uncaught (in Promise) Response {url: "http://swapi.co/api/planets/1/", ok: false, status: 0, statusText: "", headers: Headers, ...}