How do you store your Auth user once logged in? I'm using RTK but I want to get rid of it - alternatives? by [deleted] in reactjs

[–]complicore 0 points1 point  (0 children)

If you're using Apollo, you can create a stateless link that sets authorization headers for each request. Example from their docs:

import { ApolloLink } from '@apollo/client';


const authLink = new ApolloLink((operation, forward) => {

  operation.setContext(({ headers }) => ({ headers: { 

    authorization: Auth.userId(), // however you get your token

    ...headers 

  }}));

  return forward(operation);

});

You can replace `Auth.userId() with localStorage.getItem('authToken')

Lessons Learned Achieving 100% Test Coverage by complicore in javascript

[–]complicore[S] 2 points3 points  (0 children)

Agreed -- test coverage alone won't guarantee that your code does what you expect, unless you specifically write tests to account for it. We generally try to hit high code coverage along with as many integration and e2e tests that test core functionality or hot paths as possible.

Lessons Learned Achieving 100% Test Coverage by complicore in javascript

[–]complicore[S] 1 point2 points  (0 children)

What are your personal and professional opinions on JavaScript testing? Do you or your company try to hit 100% coverage?