LaravelのREST APIで下記のようなJSONデータを吐き出しています。
これをVueJSで受け取るにはどのようにすべきでしょうか。
現状、VueJsのDevツールでデータセット用に用意したDataListには、ただの文字列が入っている状態です。(”[{"id":1,"name":..},]”)
json
1[ 2 { 3 "id":1, 4 "name":"\test", 5 "url":"https...", 6 "created_at":"2018-04-30 00:00:00", 7 "updated_at":"2018-04-30 00:00:00" 8 }, 9 { 10 "id":2, 11 "name":"DAS\u5c0f\u5c71", 12 "address":"test", 13 "url":"https...", 14 "created_at":"2018-04-30 00:00:00", 15 "updated_at":"2018-04-30 00:00:00" 16 }, 17]
javascript
1<script> 2export default { 3 data () { 4 return { 5 DataList : [], 6 } 7 }, 8 mounted : function() { 9 get(`/api/data`) 10 .then((res) => { 11 this.DataList = res.data; 12 }) 13 .catch((err) => { 14 if(err.response.status === 422) { 15 this.error = err.response.data 16 } 17 this.isProcessing = false 18 }) 19 20 }, 21} 22</script>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/01 09:22