NuxtとLaravelとのAPI通信で取得したURLをサムネイルとして表示したいです。
"nuxt": "^2.15.3"
"laravel/framework": "^6.20.26"
axiosでURLを入力されたURLをpostしています
Input.vue
<template> <el-form label-width="80px"> <label for="thumbnailurl">サムネイルURL:</label> <input id="thumbnailurl" type="text" v-model="channelData.thumbnail"> <el-button @click="createchannel" type="primary" round>登録</el-button> </el-form> </template> <script> import axios from 'axios'; export default { data() { return { channelData: { thumbnail: '' }, }; }, methods: { createchannel(){ axios.post('http://localhost:8000/api/test', { thumbnail_url: this.channelData.thumbnail, }) .then(res => { console.log(res); this.channelData = res.data; }).catch(error => { console.log(error.response); }); } } } </script>
送られたURLをLaravelでデータベースに保存しています。
サムネイルに変換する処理をここで行うのかも?
コントローラー
public function store(Request $request) { $channel = new Channel; $channel->thumbnail_url = $request->input('thumbnail_url'); $channel->save(); }
あなたの回答
tips
プレビュー