Giter VIP home page Giter VIP logo

Comments (9)

hkjels avatar hkjels commented on June 16, 2024 1

Superapi works, it's just hacky. I'd prefere something like.

var Superapi = require('superagent');
var request = new Superagent(options)

But that's a breaking change.
I guess something like:

request.setDefaultHeader('name', 'content');

would be a saner way of going about it at this point.

from superagent.

hkjels avatar hkjels commented on June 16, 2024

Perhaps add setBaseurl and auth or sign?
I've just now created a little hack on superagent to work with APIยดs myself.
hkjels/superapi

from superagent.

hallas avatar hallas commented on June 16, 2024

what about a notion of "arch requests" or "prototype requests"?

var req = request.get(...).header(...);
req.clone().header(a).end();
req.clone().header(b).end();

from superagent.

smeijer avatar smeijer commented on June 16, 2024

Any progress on this? I really need some defaults. Like authentication headers and request retry on token-expiry.

from superagent.

anthonator avatar anthonator commented on June 16, 2024

๐Ÿ‘ being able to set a base url and default headers would be awesome.

from superagent.

cgarvis avatar cgarvis commented on June 16, 2024

+1

from superagent.

anthonator avatar anthonator commented on June 16, 2024

Here's a wrapper I'm using on a project for managing defaults. This specific example is used for setting a base URL. You can chain other defaults as well. I typically use this as a default and then create another wrapper around this for my app or endpoint specific defaults.

https://gist.github.com/anthonator/0dc0310a931398490fab

from superagent.

gjohnson avatar gjohnson commented on June 16, 2024

Not until after 1.0

from superagent.

defunctzombie avatar defunctzombie commented on June 16, 2024

Closing. I think this could be done via plugins. We may think about something better down the road. Wrapper seems like a reasonable solution for now.

from superagent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.