我想从agent.vue文件向agents_controller中的download_profile方法获取获取请求。我无法弄清楚如何向特定的download_profile方法发出请求。请帮助我解决此问题。
我需要在downloadProfile方法中的axios请求中提及特定方法。
<template>
<v-card class="mb-12">
<v-form :model='agent'>
<a href="#" @click.prevent='downloadProfile(agent)'>
<span>Download</span>
</a>
</v-form>
</div>
</v-card>
</template>
<script>
export default {
data: function () {
return {
agent: {
id: '',
name: ''
}
}
}
methods: {
downloadProfile(agent) {
this.$axios.get('/agent.json', { agent: this.agent })
},
}
}
</script>
agents_controller.rb
def download_profile
puts params
end
routes.rb
get :agent, to: 'agent#download_profile', constraints: ->(req) { req.format == :json }
您可以尝试在您的get请求中添加“ responseType:'arraybuffer'”