-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow response.text() don't always assume json #11
Comments
One thing we're going to have to consider is that some middleware will need to be chained (modifying the response after it's been transformed to JSON or text) and others will need to replace whatever functionality we have in place (such as actually doing |
Yep. I know. Trying to think of a good way to handle it. |
Piggybacking off of #17, we could add a property import { partial } from 'legible'
const twitter = {
register: partial`
url: https://api.twitter.com/register,
method: POST
headers: ${{ Authorization: localStorage.getItem('authorization') }}
responseType: text
`
} |
And just default it to json. Sounds good. Now we can do middleware like this: import { middleware } from 'legible'
const test = request => async function(next) {
//request is the whole object from normalize
//response is the response obviously. Call next to get it
let response = await next(request)
console.log(response)
}
const test = request => next => {
//modify the request
next({url: 'http://blah.com', options: request.options })
}
middleware.add(test) I like that and it's simple! |
What if we add this ability into the middleware?
Something like that? Not sure how I feel about the syntax but we need some way to have access to every piece of the request and modify it
The text was updated successfully, but these errors were encountered: