Skip to content
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

reqOptions as a function #9

Closed
viktor-ku opened this issue May 8, 2018 · 1 comment
Closed

reqOptions as a function #9

viktor-ku opened this issue May 8, 2018 · 1 comment

Comments

@viktor-ku
Copy link
Contributor

Hi

Problem

There is a certain case when you need to to check auth with updated headers, cause it makes sense, right?

In my project right now I am hacking this stuff by creating an options object somewhere and accessing it like that

import checkAuthOptions from '../lib/checkAuthOptions'

Then I'd modify it and because it's reference check auth will use updated object

Another way to do it is via observables but I don't want to bring them just to use in this case.

Proposal

So my proposal is to make reqOptions either a function or object. So I'd write

const reqOptions = () => ({
  method: 'POST',
  headers: {
    Authorization: localStorage.getItem('awesomeness-token')
  }
})

And before doing any fetch check auth would execute this function to get current tokens and everything.

Backward Compatibility

To maintain backward compatibility we can pass reqOptions as an object or a function

@karthikvt26
Copy link
Collaborator

Resolved by #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants