ethanent / phin

Node HTTP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type for options for POST request not exported

jdforsythe opened this issue · comments

The type used for POST requests is IWithData<phin.IOptions> but the IWithData is not exported in types.d.ts so there's no way to construct a typed options object without making a custom type.

Also, there's a note in the types about using the generics to make JSON/Form posting mutually exclusive, but wouldn't this work just as well?

export interface IOptions extends IOptionsBase {
 parse?: 'none'
}

interface WithData {
  data: object;
}

interface WithForm {
  form: {
    [index: string]: string;
  }
}

export type IOptionsWithData = IOptions & WithData;
export type IOptionsWithForm = IOptions & WithForm;
// etc
commented

Thanks for pointing that out. A PR would be appreciated!

@ethanent PR submitted #65

I kept the generics but explicitly made the T extend IOptionsBase and updated the data property of IWithData to be compatible with what Centra accepts.