
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
parrot-mocker
Advanced tools
This package supports to intercept XHR/JSONP/Fetch requests and forward to the specified mock server.
Install from Chrome web store.
Or load the plugin by following Google's development guide. The plugin folder is crx
.
If the development mode plugin is disabled by Chrome, you can uninstall and install it again.
<head>
<!-- Make sure to be loaded first -->
<script type="text/javascript" src="dist/parrot.js"></script>
</head>
// Modifiy webpack.config.js to prepend this package to dependencies of each entry
module.exports = {
entry: ['parrot-mocker', './yours/src/entry.js']
};
We export a function to rewrite the request url.
string
the url of the API requeststring
the type of request, like jsonp
string
the url of the pagestring
the cookie of the page requestfunction
skip rewritting if returns true. By default, no host or including local
will be filtered. Its arguments are:
string
the API hostFor example, let's make a simple middleware for Koa,
var fetch = require('node-fetch');
var wrapUrl = require('parrot-mocker').wrapUrl;
module.exports = function*(next) {
this.fetch = (url, options) => {
return fetch(wrapUrl(url, {
pageUrl: this.url,
cookie: this.header.cookie
}));
};
yield* next;
};
FAQs
Intercept requests to the mock server
The npm package parrot-mocker receives a total of 3 weekly downloads. As such, parrot-mocker popularity was classified as not popular.
We found that parrot-mocker 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.