Why can't I access the Shopify API during preview mode?

If you're reading this, you may be wondering why your task doesn't seem to be able to access the Shopify API, while you work on the task script. Read on!

A task is always run in response to an event. However, for several purposes, Mechanic may also run your task with a preview event, without performing any of the actions the task generates.

We refer to this as "preview mode", and it's used for...

  • Showing merchants what actions they can expect the task to perform (read more about preview actions)
  • Determining what permissions the task requires in order to run
  • Performance-related analysis

Because all of these purposes require very fast performance of the task, Mechanic disallows all API requests during preview mode. You can use the {{ event.preview }} variable to make decisions about what should happen during preview mode, like creating stub data that results in the appropriate actions being rendered during preview – a good practice when accounting for preview actions.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.