前提・実現したいこと
csvをアップロードして中身を確認したいです。
発生している問題・エラーメッセージ
http://localhost:8080/ 404 (Not Found)
該当のソースコード
vue
1<template> 2 <div id="test"> 3 <v-layout justify-center align-center column > 4 <input @change="selectedFile" type="file" name="file"> 5 <v-btn @click="upload" color="primary" dark large>実行</v-btn> 6 </v-layout> 7 </div> 8</template> 9 10 11 12<script> 13import axios from 'axios' 14 15export default { 16 el: '#test', 17 data: { 18 uploadFile: null 19 }, 20 methods: { 21 selectedFile: function(e) { 22 // 選択された File の情報を保存しておく 23 e.preventDefault(); 24 let files = e.target.files; 25 this.uploadFile = files[0]; 26 console.log(this.uploadFile) 27 }, 28 upload: function() { 29 // FormData を利用して File を POST する 30 let formData = new FormData(); 31 formData.append('yourFileKey', this.uploadFile); 32 let config = { 33 headers: { 34 'content-type': 'text/csv' 35 } 36 }; 37 axios 38 .post('http://localhost:8080/#/list/cover', formData, config) 39 .then(function(response) { 40 // response 処理 41 }) 42 .catch(function(error) { 43 console.log(error); 44 }) 45 } 46 } 47 }; 48</script> 49 50 51<style> 52</style> 53
試したこと
postの第一引数が間違いなのかと思い
実際に実行したrouteのURLではなくhttp://localhost:8080としましたが
変わりませんでした。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2019/01/31 07:08
2019/01/31 07:10
退会済みユーザー
2019/01/31 07:13
退会済みユーザー
2019/01/31 07:33 編集