Browse Source

docs: Fix incorrect RequestContext serialization method (#3365)

Rahul Raj Yadav 9 months ago
parent
commit
34578cbf52
1 changed files with 5 additions and 4 deletions
  1. 5 4
      docs/docs/guides/developer-guide/worker-job-queue/index.mdx

+ 5 - 4
docs/docs/guides/developer-guide/worker-job-queue/index.mdx

@@ -326,8 +326,9 @@ export class ProductVideoPlugin {}
 
 Sometimes you need to pass the [RequestContext object](/reference/typescript-api/request/request-context) to the `process` function of a job, since `ctx` is required by many Vendure
 service methods that you may be using inside your `process` function. However, the `RequestContext` object itself is not serializable,
-so it cannot be passed directly to the `JobQueue.add()` method. Instead, you can serialize the `RequestContext` using the [`RequestContext.serialize()`
-method](/reference/typescript-api/request/request-context/#serialize), and then deserialize it in the `process` function using the static `deserialize` method:
+so it cannot be passed directly to the `JobQueue.add()` method. Instead, you can serialize the `RequestContext` using the [`ctx.serialize()` method](/reference/typescript-api/request/request-context/#serialize),
+ and then deserialize it in the `process` function using the static `deserialize` method.
+
 
 ```ts
 import { Injectable, OnModuleInit } from '@nestjs/common';
@@ -358,7 +359,7 @@ class ProductExportService implements OnModuleInit {
 
     exportAllProducts(ctx: RequestContext) {
         // highlight-next-line
-        return this.jobQueue.add({ ctx: RequestContext.serialize(ctx) });
+        return this.jobQueue.add({ ctx: ctx.serialize() });
     }
 }
 ```
@@ -468,7 +469,7 @@ class ProductExportService implements OnModuleInit {
     }
 
     exportAllProducts(ctx: RequestContext) {
-        return this.jobQueue.add({ ctx: RequestContext.serialize(ctx) });
+        return this.jobQueue.add({ ctx: ctx.serialize() });
     }
 }
 ```