
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
axios-json-mock
Advanced tools
Axios helper that allows to easily mock request
Using npm:
npm install axios-json-mock --save
axios-json-mock works on Node as well as in a browser, it works with axios v0.16.0 and above.
Mocking a GET
request
import axios from 'axios';
import AxiosJsonMock from 'axios-json-mock';
// Set default axios instance
const instance = new AxiosJsonMock(axios);
const responseWith = {
200: [
{ id: 23, name: 'John Lennon' }
],
400: {
message: 'Bad Request'
}
}
// arguments for instance are (request config, mock config)
instance({ url: '/users' }, {
useMock: true,
responseWith
})
.then(response => console.log(response.data))
Add a specify status code
// arguments for instance are (request config, mock config)
instance({ url: '/users' }, {
useMock: true,
statusCode: 400,
responseWith
})
.catch(response => console.error(response))
To add a delay to responses, specify amout (in milliseconds)
const instance = new AxiosJsonMock(axios, { timeout: 1000 });
Using a mocks folder with json files
āāā __dirname
ā āāā __mocks__
ā ā āāā userlist.json
ā ā āāā *.json
ā ā āāā *.json
userlist.json
{
"200": [
{ "id": 23, "name": "John Lennon" }
],
"400": {
"message": "Bad Request"
}
}
import axios from 'axios';
import AxiosJsonMock from 'axios-json-mock';
// Set default axios instance with mocks folder
const instance = new AxiosJsonMock(axios, { mockFolder: __dirname + '__mocks__' });
instance({ url: '/users' }, {
useMock: true,
mockName: 'userlist' // set json filename
})
.then(response => console.log(response.data))
Turn off mocks and make real request
instance({ url: '/users' }, {
useMock: false,
mockName: 'userlist' // set json filename
})
.then(response => console.log(response.data)) // real data
FAQs
Axios helper that allows to easily mock requests
The npm package axios-json-mock receives a total of 4 weekly downloads. As such, axios-json-mock popularity was classified as not popular.
We found that axios-json-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.