Skip to content

contextToJson ​

Category
Tags
Export size
min 5.75 kB · gzip 2.39 kB

Converts a FeathersJS HookContext to a plain JSON object by calling toJSON() if available. This is important when reading the context by path, since the HookContext class uses getters that may not be enumerable.

ts
  import { 
contextToJson
} from 'feathers-utils/utils';

Example ​

ts
import { contextToJson } from 'feathers-utils/utils'

const json = contextToJson(context)
console.log(json)

Type declaration ​

Show Type Declarations
ts
/**
 * Converts a FeathersJS HookContext to a plain JSON object by calling `toJSON()` if available.
 * This is
 *
 * const json = contextToJson(context)
 * console.log(json)
 * ```
 *
 * @see https://utils.feathersjs.com/utils/context-to-json.html
 */
export declare const contextToJson: (
  context: HookContext,
) => HookContext<Application<any, any>, any>
ArgumentTypeDescription
contextHookContext

Released under the MIT License.