Calling getView() and getting relationship data

Created on 8 September 2023, about 1 year ago
Updated 18 September 2023, about 1 year ago

Hi,

I had a quick question relating to the getView function. How can I get a field if that field uses a relationship?

So far I have this:

const companies_carousel = await drupal.getView(
    "companies--homepage_companies_carousel",
    {
      locale: "en",
      defaultLocale: "el",
      params: {
        include: "field_company_logo.field_media_image",
      },
    }
  );

This allows me to get the company logo but I need another field which are the number of job vacancies this company has. The Job content type has a field_company entity reference field and in Views I simply add that as a relationship to get Job fields related to each company. I can get this just fine using Views but I don't know how to send it through Next.js for Drupal.
Would appreciate any help you can give me.

πŸ’¬ Support request
Status

Active

Version

1.6

Component

Code

Created by

πŸ‡¨πŸ‡ΎCyprus EliasPapa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024