Consuming the API in the application
To be able to build the UI without the API functionality, we used test data on our pages. Now, we want to replace it with the real queries and mutations that we just made for communicating with the API.
Public organization
We need to replace a couple of things now.
Let’s open src/pages/organizations/[organizationId]/index.tsx
and remove the following:
import { getJobs, getOrganization, } from '@/testing/test-data';
Now, we must load the data from the API. We can do that by importing getJobs
and getOrganization
from corresponding features
. Let’s add the following:
import { JobsList, Job, getJobs } from '@/features/jobs'; import { getOrganization, OrganizationInfo, } from '@/features/organizations';
The new API functions are a bit different, so we need to replace the following code:
const [organization, jobs] = await Promise.all([ &...