Skip to content
Advertisement

Using an empty string in path fails

In my node API i have some function that updates the email address Array of either a contact or a farm, its the same concept but the difference is where the array is located in farms is in Records.emails and in Contacts its in emails. So in my case I decide based on _type what the path is.

JavaScript

In case the emailPath is ” which happens to be the case for Contact it cant get the data. So i am wondering if there is a way to make this work other then using

JavaScript

Advertisement

Answer

You can’t do it like that, and more so, you don’t need too.

  1. Define a variable that will receive the value of emails.
  2. Use the conditional to disambiguate the input
  3. Copy the emails from where it resides in the input, based on type
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement