mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-07-15 21:13:35 +02:00
Many fixes!
This commit is contained in:
20
lib/index.js
Normal file
20
lib/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const common = [ 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH' ];
|
||||
const request = require('./model/WumpRequest');
|
||||
const { version } = require('../package.json');
|
||||
|
||||
module.exports = (url, method) => {
|
||||
return new request(url, method);
|
||||
};
|
||||
|
||||
common.forEach((v) => {
|
||||
module.exports[v.toLowerCase()] = (url, method) => {
|
||||
if (typeof url === 'string') {
|
||||
return new request(url, { method: v, ...method });
|
||||
} else {
|
||||
return new request({ method: v, ...url }, method);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.version = version;
|
||||
module.exports.userAgent = `wumpfetch/${version} (https://github.com/PassTheWessel/wumpfetch)`;
|
||||
Reference in New Issue
Block a user