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

docs: Documentation only changes #1433

Open
wants to merge 1 commit into
base: v4
Choose a base branch
from
Open

Conversation

Sindhani
Copy link

@Sindhani Sindhani commented Nov 28, 2022

docs: Documentation only changes

added Missing docs for sending custom or bearer headers.
@Sindhani Sindhani changed the title added missing docs for sending authorization header i.e., Bearer or custom headers docs: Documentation only changes Nov 28, 2022
Comment on lines +442 to +443
// createUploadLink can be used as well
// jaydenseric/apollo-upload-client library for uploading files using apollo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think file upload should be mentioned at all in vue-apollo docs, it's unrelated

Comment on lines +445 to +458
let link = createHttpLink({uri: url})
link = setContext(async (_, {headers}) => {

// getToken() your defined function for getting the token
const Authorization = getToken()

const authorizationHeader = Authorization ? {Authorization} : {}
return {
headers: {
...headers,
...authorizationHeader,
},
}
}).concat(link)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doing a few things in not-the-most-readable way.
What about having a separate const httpLink = ... and const authorzationHeaderLink = ... and then const link = authorzationHeaderLink.concat(httpLink)?

Authorization should probably not be uppercased, it's just a string.
And the code style in the docs has spaces inside curly braces.

Comment on lines +460 to +463
function getToken() {
const token = JSON.parse(localStorage.getItem('apollo-token'));
return `Bearer ${token}` || null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be not included, getting the token shouldn't be part of the example IMO, wdyt @Akryum?

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

Successfully merging this pull request may close these issues.

None yet

2 participants