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

Create Customer Service (Angular - Fetch All Customers) #19

Open
hazartilirot opened this issue May 19, 2023 · 1 comment
Open

Create Customer Service (Angular - Fetch All Customers) #19

hazartilirot opened this issue May 19, 2023 · 1 comment

Comments

@hazartilirot
Copy link

Actually, the solution shown in the video is incorrect since we have protected the route /api/v1/customers

We need to add a token each time we request. There should be something like the following:

findAll(): Observable<CustomerDto[]> {
        return this.http.get<CustomerDto[]>(
            "http://localhost:8080/api/v1/customers", {
                headers: new HttpHeaders({
                    "Authorization": `Bearer ${localStorage.getItem("token")}`
                })
            }
        );
    }
@hazartilirot
Copy link
Author

Well, the fellow grabs the token and hardcodes it into the GET request - which is absolutely unnecessary. I set 60 minutes for a token to be valid.

It's the first time I watch a course with Angular. What a pity the fellow doesn't explain it wait.... you feel like you're a kind of a parrot that is supposed to repeat after him. I'm pretty much positive, there must be a kind of interception to include our token to all httpClient request.... why bother?

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

1 participant