Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: delay undefined #289

Closed
alecthw opened this issue Apr 7, 2022 · 3 comments
Closed

Bug: delay undefined #289

alecthw opened this issue Apr 7, 2022 · 3 comments

Comments

@alecthw
Copy link

alecthw commented Apr 7, 2022

Node: v16.14.2
Mocker Api: 2.9.5

mock\index.js

const { delay } = require('mocker-api');
const noProxy = process.env.NO_PROXY === 'true';

const proxy = {
  'GET /api/user': {
    id: 1,
    username: 'kenny',
    sex: 6,
  },
};

module.exports = noProxy ? {} : delay(proxy, 1000);

run with cmd

mocker mock
> mocker mock        

D:\WebstormProjects\my-parcel\mock\index.js:12
module.exports = noProxy ? {} : delay(proxy, 1000);
                                ^

TypeError: delay is not a function
    at Object.<anonymous> (D:\WebstormProjects\my-parcel\mock\index.js:12:33)   
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) 
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at D:\WebstormProjects\my-parcel\node_modules\mocker-api\lib\index.js:200:32
    at Array.reduce (<anonymous>)
    at getConfig (D:\WebstormProjects\my-parcel\node_modules\mocker-api\lib\index.js:199:27)

debug image
image

@jaywcjlove
Copy link
Owner

@alecthw const delay = require('mocker-api/lib/delay');

你先使用这种方式解决一下,我看一下什么情况

@jaywcjlove
Copy link
Owner

const delay = require('mocker-api/lib/delay');

jaywcjlove added a commit that referenced this issue Apr 7, 2022
jaywcjlove added a commit that referenced this issue Feb 17, 2023
jaywcjlove added a commit that referenced this issue Feb 17, 2023
github-actions bot pushed a commit that referenced this issue Feb 17, 2023
@jaywcjlove
Copy link
Owner

const delay = require('mocker-api/delay');
// or
const delay = require('mocker-api/lib/delay');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants