微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

“所选项目无效” - NextJS + Laravel / 422 错误

如何解决“所选项目无效” - NextJS + Laravel / 422 错误

我有这个问题... 我创建了一个新的地点记录,然后我检查它是否存在。

enter image description here

到目前为止一切顺利,但是现在当我想将它链接到某个餐厅时,它返回422 错误

enter image description here

我一直在寻找答案,但我不明白我做错了什么。

这是我的代码

    public function store(Request $request){

    $this->authorize('create',Feeding::class);

    $request->validate([
        'date' => 'required|date|max:255','food' => 'required|string|max:255','observation' => 'required|string','quantityLunchs' =>'required|integer','user_id' => 'required|exists:users,id','artist_id' => 'required|exists:artists,'place_id' => 'required|exists:places,],self::$messages);

    $Feeding = Feeding::create($request ->all());
    return response() -> json($Feeding,201); //success
}

我在邮递员中使用的标题

授权:不记名令牌

接受: application/json

有什么解决办法吗? 坦克你

解决方法

好的,我解决了。

我不得不在这里替换:

enter image description here

因为我想链接feeding_places,不链接places 呜呜! ?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。