@laura-wert/axios-intercept-mock-adapter
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Axios intercept mock adapter

this is een extension off https://github.com/ctimmerm/axios-mock-adapter

It adds the possibility to intercept and modify the original response

you always need to add the folowing line after the intercepts

mock.onAny().passThrough()

#example

import client from 'src/domains/api/client'
import MockInterceptAdapter from '@laura-wert/axios-intercept-mock-adapter'

const mock = new MockInterceptAdapter(client)

mock.interceptGet('/me/orders')
  .transformResponse((data: Order[]): void => {
    data[0].id = 100
  })

mock.interceptGet(/me\/order\/[0-9]*)
  .transformResponse((data: ILevelSubject): void => {
    console.log(data, process.env)
  })

mock.onAny().passThrough()

s

Readme

Keywords

none

Package Sidebar

Install

npm i @laura-wert/axios-intercept-mock-adapter

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

46.7 kB

Total Files

9

Last publish

Collaborators

  • rickyrick
  • martijng788