Skip to content

paramsForServer

hooks
Source Code | Documentation

See also: hooks/paramsFromClient

Client-side hook that moves whitelisted params properties into query._$client so they survive the client-to-server transport. The server only receives query from params — use paramsFromClient on the server to restore them.

ts
  import { 
paramsForServer
} from 'feathers-utils/hooks';

Example

ts
import { paramsForServer } from 'feathers-utils/hooks'

// Client-side
app.service('users').hooks({
  before: { all: [paramsForServer('populateParams')] }
})

Type declaration

Show Type Declarations
ts
export type ParamsForServerOptions = {
  /**
   * @default '_$client'
   */
  keyToHide?: string
}
/**
 * Client-side hook that moves whitelisted `params` properties into `query._$client`
 * so they survive the client-to-server transport. The server only receives `query`
 * from params — use `paramsFromClient` on the server to restore them.
 *
 * @example
 * ```ts
 *
 *
 * // Client-side
 * app.service('users').hooks({
 *   before: { all: [paramsForServer('populateParams')] }
 * })
 * ```
 *
 * @see https://utils.feathersjs.com/hooks/params-for-server.html
 */
export declare const paramsForServer: (
  whitelist: MaybeArray<string>,
  options?: ParamsForServerOptions,
) => <H extends HookContext>(context: H, next?: NextFunction) => any
ArgumentTypeDescription
whitelistMaybeArray<string>
optionsParamsForServerOptions
typemethodsmulti
before, aroundcreate, update, patchyes

Released under the MIT License.