Solved

Single References Entity

  • 12 August 2022
  • 1 reply
  • 33 views

Badge

When in content stack I setup a single reference in a Content Type to another Content Type that is coming back from the API as an array. Simple example: I have a Content Type called Dog, which has a single reference to an Owner (another Content Type). When I retrieve a dog from the api (/dog/entries?environment=nonprod&locale=en-us&include[]=owner&include_branch=false) I get back a response where owner is an array (this doesn’t make sense to me). Even though in the Content Type settings I can set the reference to 1 or many and have set it to 1. I am wondering if I’m doing something wrong or if this is expected behavior. 

icon

Best answer by nick.nguyen 12 August 2022, 20:13

View original

1 reply

Userlevel 4

Hey @jonatr35 ,

This is expected behavior. References always return an array. By having references always be Array’s, then you can always expect to fetch and parse references whether its 1 or 1 to many in the same fashion. You have the option to leave it as single or select multiple. If the requirements for the reference field fall under different needs, then the users will know based on the selected options. 

Reply