Hello, I encountered a CORS error when accessing the KoboToolbox API from my Vue.js application. I noticed that the ‘Access-Control-Allow-Origin’ CORS header is missing from the server response when I use the ‘https://kobo.humanitarianresponse.info’ server. However, when I tested it on Postman, I found that everything works perfectly. Can you please guide me on how to configure the KoboToolbox server to allow cross-origin requests when using this server? Alternatively, is there another way to work around this error? Thank you for your assistance.
Here is the code I am using to access the API:
<template>
<div>
<h1>Form Data</h1>
<ul>
<li v-for="data in formData" :key="data._id">
{{ data.name }} - {{ data.age }}
</li>
</ul>
</div>
</template>
<script>
export default {
data() {
return {
formData: []
}
},
async mounted() {
const response = await fetch('https://kobo.humanitarianresponse.info/api/v2/assets/my_uid/data.json', {
headers: {
Authorization: 'Token my_token'
}
})
this.formData = await response.json()
}
}
</script>
image :