#Lesson 5.2 - Add remote fields
In this lesson, you will add a remote field to the Product model. Remote fields fetch data from a remote source in the context of a specific model entry. The field uses a value from the entry itself, in this case productSlug, as the argument passed to the external API, so the reviews returned are always scoped to that product.
This is different from a top-level remote field, which fetches remote data independently of any entry. That is covered in lesson 5.3.
#Add a remote field to the Product model
You will use the HyDemoAPI remote source configured in lesson 5.1 to add a Reviews field to the Product model.
-
Open the Product model in the Schema editor and from the right sidebar, add a REST remote field.
-
Fill in the following information:
Field Input Display name Reviews API ID Auto-completed. Leave as is. Remote source HyDemoAPI is selected by default. Leave as is. Method GET is selected by default. Leave as is. Return type Select Reviewsfrom the dropdownPath /api/reviews/product/{{doc.productSlug}}The
Pathappends to the remote source base URL.{{doc.productSlug}}references theproductSlugfield on the currentProductentry, which scopes the review data to that specific product. -
Click Add to save.
#What's next
Lesson 5.3 - Add top-level remote fieldsOr, go to the Tutorial overview for the full lesson list.