preRequest.ts 583 B

1234567891011121314151617181920
  1. import { runPreRequestScript } from "@hoppscotch/js-sandbox"
  2. import { Environment } from "@hoppscotch/data"
  3. import cloneDeep from "lodash/cloneDeep"
  4. import {
  5. getCurrentEnvironment,
  6. getGlobalVariables,
  7. } from "~/newstore/environments"
  8. export const getCombinedEnvVariables = () => ({
  9. global: cloneDeep(getGlobalVariables()),
  10. selected: cloneDeep(getCurrentEnvironment().variables),
  11. })
  12. export const getFinalEnvsFromPreRequest = (
  13. script: string,
  14. envs: {
  15. global: Environment["variables"]
  16. selected: Environment["variables"]
  17. }
  18. ) => runPreRequestScript(script, envs)