第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在我的 API 請求中出現(xiàn)“語法錯(cuò)誤:”JSON.parse:JSON 數(shù)據(jù)第 1 行第 1 “

在我的 API 請求中出現(xiàn)“語法錯(cuò)誤:”JSON.parse:JSON 數(shù)據(jù)第 1 行第 1 “

PHP
四季花海 2023-05-26 10:00:52
基本上我已經(jīng)使用 laravel 7 和 Vue.js 制作了一個(gè)名為 observations 的“簡單”API,我的 GET 請求正在運(yùn)行但我無法執(zhí)行我的 DELETE 和 POST 請求,我不得不說我仍在學(xué)習(xí) Laravel 所以可能會(huì)有很多錯(cuò)誤。這里很少評論:DELETE 實(shí)際上有效(它刪除),它只是不重新加載所有觀察結(jié)果,因?yàn)樗鼞?yīng)該是預(yù)期的這是我的 vue 組件:<template>    <div>        <div class="card card-header">            <h2> observaciones </h2><small> para futuras donaciones </small>        </div>        <div class="card card-body" v-for="observation in observations" v-bind:key="observation.id">            <h4> {{observation.name}}</h4>            <p> {{observation.content}}</p>            <button class="btn btn-danger btn-block" @click="deleteObservation(observation.id)"> Borrar </button>        </div>        <!-- FORMULARIO PARA AGREGAR OBSERVACION -->        <div class="card card-footer">            <form @submit.prevent="addObservation">                <!-- <div class="form-group">                    <input type="text" class="form-control" placeholder="nombre" v-model="observation.name">                </div> -->                <div class="form-group">                    <textarea type="text" name="content" class="form-control" placeholder="algun texto" v-model="observation.content">                    </textarea>                </div>                <button type="submit" class="btn btn-primary btn-block"> Agregar observacion </button>            </form>        </div>    </div></template><script>    export default{        data(){            return{                observations:[],                observation:{                    id:'',                    name:'',                    content:''                }            }        },        created(){            this.fetchObservations();        },        methods:{            fetchObservations(){                fetch('api/observations')                .then(res=> res.json())                .then(data=>{                    this.observations= data;                    console.log(data);                });            },</script>
查看完整描述

1 回答

?
撒科打諢

TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊

因?yàn)槟鉹eturn null;在你的destroy方法中,所以在你的前端,當(dāng)你試圖將它解析為 json 時(shí),它會(huì)拋出一個(gè)錯(cuò)誤。


嘗試這個(gè)。


            deleteObservation(id){

                if(confirm('?Estas Seguro?')){

                    fetch('api/observations/+id',{

                        method:'delete'

                    })

                    .then(()=>{

                        fetchObservations();

                    })

                    .catch(err=> console.log(err));

                }

            }


查看完整回答
反對 回復(fù) 2023-05-26
  • 1 回答
  • 0 關(guān)注
  • 168 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號