コード– category –

-
Cannot invoke an object which is possibly ‘undefined’.
In this article, I will show you how to solve the problem of "Cannot invoke an object which is possibly 'undefined'. In this article, I will show you how to solve the problem when you get the error "Cannot invoke an object which is possi... -
Cannot invoke an object which is possibly ‘undefined’.
この記事ではtypescriptで「Cannot invoke an object which is possibly 'undefined'.」というエラーが出たときの解決方法をご紹介します。 このエラーが出る型定義は以下の通りです。 export type ButtonProps = { ... handleOnClick?: () => void; };... -
[Next.js] Using axios to get data with SWR
I will show you how to use axios to get data in Next.js SWR. The API server is assumed to be Laravel.We also assume that Laravel is using Eloquent's API Resources when returning data. https://laravel.com/docs/8.x/eloquent-resources So, w... -
Upgrade to PHP8.0 and install Laravel8 on EC2 (Amazon Linux2)
I upgraded PHP7.2 to PHP8.0 on EC2 using Amazon Linux2 and installed Laravel8.Here is how I did it. Command to use The following is a list of commands used in this article with a light explanation.If you are in a hurry, please refer to t... -
【Next.js】useSWR()でPOSTする
useSWR()を使ってデータを取得するには以下の方法で取得できました。 const commentsFetcher = (url: string): Promise<fetchCommentsReturnType> => axios(url).then((res) => res.data); const { data: comments, error:commentsError } = u... -
【Next.js】axiosを使ってSWRで取得する
Next.jsのSWRでデータを取得するときにaxiosを使った方法をご紹介します。 APIサーバーはLaravelを想定しています。また、Laravelでデータを返すときはEloquentのAPI Resourcesを使用しているものとします。 https://laravel.com/docs/8.x/eloquent-resour... -
Laravel でtwitterのフォロー機能を実装する
Laravelでtwitterのフォローのような機能を作る時は、以下のようなパッケージをcomposerでインストールして実装ができます。 overtrue/laravel-followhareku/laravel-follow しかし、このようなパッケージを入れなくてもtwitterのようなフォロー機能をシン... -
Laravelでリレーションの外部キーにnullを許可する
この記事でLaravelのリレーションで外部キーにnullを許可する以下の2つの方法をご紹介します。 バージョンに関係ない共通の書き方Laravel >= 7.x でforeignId()を使う方法 Laravel >= 7.x を使っている場合はforeignId()を使用した方法をおすすめし... -
EC2のLaravelにintervention/imageをインストール
あるウェブサービスで容量の大きい画像(2〜数十MB)の画像加工をして保存するロジックで、 「500 リクエストを処理できません。」 とエラーが出て画像を加工・保存できないことがあります。 この記事ではLaravelでintervention/imageを使って画像を加工・... -
EC2(Amazon Linux2)でPHP8.0にバージョンアップしてLaravelをインストール
Amazon Linux2を使ったEC2のPHP7.2をPHP8.0にバージョンアップしてLaravelをインストールしました。その方法をご紹介します。 使用するコマンド この記事内で使用するコマンドを軽い説明付きでまとめました。お急ぎの方は以下のコマンドを参考にしてくださ...