Search code examples
javascriptreactjsreduxsuperagent

superagent dynamic method types


I'm using superagent and I faced a problem with dynamic method name. For every method I shoud write:

request
  .get(url)

request
  .post(url)

Is there any way to pass method name as parameter to superagent like that done in axios

 axios({
  method: 'post',
  url,
  data
});

Solution

  • You can also use like below check docs

    request('GET', url).end(callback);// and pass your first param as http verb 'GET','POST', etc...
    

    Instead just

    request.get(url);
    

    Or

    request.post(url);