Angular Interceptor: headers added in the request not set properly, can’t fetch them from the API

I’m trying to add some custom headers in my angular interceptor as follow: @Injectable() export class HttpJwtAuthInterceptor implements HttpInterceptor { constructor() {} intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { localStorage.setItem(‘token’, ‘qsdfqsdfqsdfqsdf’); if (localStorage.getItem(‘cuid’) && localStorage.getItem(‘token’)) { request = request.clone({ setHeaders: { ‘sm_universalid’:’blablabla’, Authorization: `Bearer ${localStorage.getItem(‘token’)}`, }, }); } return next.handle(request); } } The above interceptor was […]

Angular and jasmine: how to avoid default route to test a specific route after clicking a button

I want to test a method that use a router to navigate to another page, the method’s name is goToView(): goToView(): void { this.router.navigate([‘../’+this.view],{relativeTo:this.activeRoute}) } In my spec class I added this: describe(‘HomeRedirectionBoxComponent’, () => { let component: HomeRedirectionBoxComponent; let fixture: ComponentFixture<HomeRedirectionBoxComponent>; let location: Location; let router: Router; beforeEach(async () => { await TestBed.configureTestingModule({ declarations: […]

By extraHassan
Published
Categorized as angular, jasmine, routes, testing Tagged , , ,

angular: css style not applying to childs

I’m using a global style file which I’m applying to my whole angular application names styles.scss: "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/dashboard", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "assets": ["src/assets"], "styles": ["src/styles.scss"], "scripts": [] }, Then I created a parent component which gives me the view bellow: this is my HTML code for […]

By extraHassan
Published
Categorized as angular, bootstrap-4, css, sass, styles Tagged , , , ,

swagger generated client method not working, spring boot angular

I have a controller which has an endpoint method to generate an excel file: @RestController @RequestMapping("api/v1/report") @AllArgsConstructor @CrossOrigin @Validated @Tag(name = "report-controller", description = "Controller managing operations related to reports") public class ReportController { private final ReportServiceImpl reportService; @PostMapping(value = "/report-file", produces = MediaType.MULTIPART_FORM_DATA_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Generate the report as Excel file […]

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq