Optimizing Request Resolvers in Schema.TaggedRequest

I have a question regarding Schema.TaggedRequest or generally the Request family. While working through Ethans fantastic workshop materials, I was playing arround with Request Resolvers. I noticed at some point that I was using string URLs all over the place and I found it quite annoying. so I placed the api path of the request in the request classes itself. would that be a sensible thing to do? I kind of like it, because it relieves me of knowing what endpoint to use and the request is anyway bound to that specific path. Is there anything I am missing? On a sidenote, somewhere in my head I think I remember not to use js get, but I can't recall why. Has anybody more insights into this?
export class UpsertFormContents
  extends Schema.TaggedRequest<UpsertFormContents>()('UpsertForm', FormError, UpsertResult, { body: UpsertBody })
{}

export class CreateFormRequest
  extends Schema.TaggedRequest<CreateFormRequest>()('CreateRequest', FormError, CreateResponse, {
    formSubjectId: Schema.string,
    formTemplateId: FormTemplateId
  })
{
  get apiPath() {
    return `/createPerformanceReviewForm` as const
  }

  get params() {
    return { formSubjectId: this.formSubjectId, formTemplateId: this.formTemplateId } as const
  }
}
Was this page helpful?