getRecourceByPath is missing Type Parameter

Created on 9 August 2024, 3 months ago
Updated 14 August 2024, 3 months ago

Problem/Motivation

our getResource method accepts a type parameter:

getResource<T>(
   type,
   resourceId,
options?): Promise<T | RawApiResponseWithData<T>>

But getResourceByPath currently does not.

getResourceByPath(path, options?): Promise<unknown>

Adding a type parameter to getResourceByPath as well will make it less awkward to work with types.

Steps to reproduce

Get a resource by path and try to access a property. You'll see an evil red squiggle.

const resource = await client.getResourceByPath(slug, {
  queryString: "include=field_image",
});
console.log(resource.type);

Proposed resolution

Add the type parameter to getResourceByPath

Remaining tasks

* Implement changes
* Update tests
* Update docs

API changes

getResourceByPath will accept a type parameter.

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brianperry

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

Comments & Activities

Production build 0.71.5 2024