Skip to content

Support for differentiating URL #213

@erprilianoAbbas

Description

@erprilianoAbbas

Hi,

I have this case where this URL is being called in getLookupValue(lookupName) function on my React component :
api/lookup/?lookupName={lookupName},

then in my code I'd call that API like this :

const [title, gender, contactMethod] = await Promise.all([
  getLookupValue('TITLE'),
  getLookupValue('GENDER'),
  getLookupValue('CONTACT_METHOD')
]);

// rest of the code

Then this is how I wrote the mockData on my stories.

// other codes
parameters: {
  mockData: [
    {
        url: 'https://dummy-api.com/api/lookup/?lookupName=TITLE',
        method: 'GET',
        status: 200,
        response: [ { lookupText: 'Mr', lookupValue: 1 } ]
    },
    {
        url: 'https://dummy-api.com/api/lookup/?lookupName=GENDER',
        method: 'GET',
        status: 200,
        response: [ { lookupText: 'Male', lookupValue: 1 } ]
    },
    {
        url: 'https://dummy-api.com/api/lookup/?lookupName=CONTACT_METHOD',
        method: 'GET',
        status: 200,
        response: [ { lookupText: 'Email', lookupValue: 1 } ]
    },
  ],
}

// rest of the codes

Issue

When I debug my code, it seems only CONTACT_METHOD that successfully being mocked, then when I commented that part, GENDER was successfully being mocked. So, I'm assuming all the previous values are being overwritten by the latest value, which in this case is CONTACT_METHOD, because it has almost identical url and only distinguished by the query params.

Question

Is there any other ways to successfully handle this case using this plugin?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions