-
Djangoのchoicesフィールドのリストを取得する
この記事ではDjangoのModelで定義したchoicesをviewで取得する方法をご紹介します。 viewで取得したあとはロジックに使用したり、テンプレートに渡したりできます。 まずは、モデルで以下のようにchoicesフィールドを定義します。 class Tag(BaseModel): t... -
Django REST frameworkのSerializerでユーザー情報を取得する
Django REST framework(以下、DRF)のSerializeでユーザー情報を取得する方法をご紹介します。 この記事でのご紹介する取得する方は contextから取得CurrentUserDefaultから取得 です。 どちらも簡単にユーザー情報を取り出せるので用途に合わせて使って... -
Implementing email address authentication in an API server using Laravel
In this article, I will show you how to implement email address authentication in an API server using Laravel. In this article, we will use the MustVerifyEmail interface, which is newly implemented in Laravel 5.7.By implementing the Must... -
Laravelを使ったAPIサーバーでメールアドレス認証を実装する
この記事ではLaravelを使ったAPIサーバーでメールアドレス認証を実装する方法をご紹介します。 今回はLaravel5.7から新たに実装されたMustVerifyEmailインターフェースを使います。MustVerifyEmailインターフェースを実装することで確認メール送信が自動で... -
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...