I am new to laravel-nova and vuejs. I am sending a request to my private-api
swagger. I have tried everything i could. I changed the conf file of my apache server given here mozailla documentation on cors. I have tried putting
axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
while sending the request. it did not work. this is my vue code in laravel-nova Vue tool.
<script>
import VueButtonSpinner from 'vue-button-spinner';
export default {
components: {
VueButtonSpinner
},
data() {
return {
showTable: false,
token_utente: "7e407066-1c6a-11ec-9bbe-0aae38056063",
encoding: "na",
document_type: "na",
indirizzo: "na",
toponimo: "na",
via: "na",
comune_registro: "na",
cap: "na",
provincia_registro: "na",
codice_fiscale: "na",
partita_iva: "na",
ccia: "na",
nrea: "na",
};
},
metaInfo() {
return {
title: 'RegistroImprese',
}
},
mounted() {
//
},
methods: {
onSubmit() {
this.isLoading = true
let param = {};
param = {
'token_utente': this.token_utente,
'codici_servizi': [ this.codici_servizi ],
'document_type': this.document_type,
'encoding': this.encoding,
'partita_iva' : this.partita_iva,
'ccia' : this.ccia,
'nrea' : this.nrea,
'solo_sedi' : this.solo_sedi,
'escludi_cessate' : this.escludi_cessate,
}
Nova.request().post('my-private-api', param).then(response =>
{
this.data = response.data;
this.isLoading = false;
this.status = true;
setTimeout(() =>
{
this.status = ''
}, 2000);
}).catch(error =>
{
console.error(error)
this.isLoading = false
this.status = false //or error
})
},
}
}
</script>