Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createRequest = (url, method, body) => {
switch (method) {
case httpMethods.HEAD:
return superagent.head(url, body);
case httpMethods.GET:
return superagent.get(url, body);
case httpMethods.POST:
return superagent.post(url, body);
case httpMethods.PUT:
return superagent.put(url, body);
case httpMethods.PATCH:
return superagent.patch(url, body);
case httpMethods.DELETE:
return superagent.delete(url, body);
default:
throw new Error(`Unsupported HTTP method: ${method}`);
}
};