5.3.3. Service Constraints
This chapter lists constraints to keep in mind when creating a service.
Use Async Methods#
Medusa wraps adds wrappers around your service's methods and executes them as async methods.
So, make sure your service's methods are always async to avoid unexpected errors or behavior.
1import { MedusaService } from "@medusajs/utils"2import MyCustom from "./models/my-custom"3 4class HelloModuleService extends MedusaService({5 MyCustom,6}){7 // Don't8 getMessage(): string {9 return "Hello, World!"10 }11 12 // Do13 async getMessage(): Promise<string> {14 return "Hello, World!"15 }16}17 18export default HelloModuleService
Was this chapter helpful?