File

json-api/src/interceptor.ts

Implements

HttpInterceptor

Index

Methods

Methods

intercept
intercept(req: HttpRequest, next: HttpHandler)
Parameters :
Name Type Optional
req HttpRequest<any> No
next HttpHandler No
Returns : any
import {
	HttpInterceptor,
	HttpHandler,
	HttpRequest,
	HttpHeaderResponse,
	HttpProgressEvent,
	HttpResponse,
	HttpSentEvent,
	HttpUserEvent,
	HTTP_INTERCEPTORS
} from '@angular/common/http';
import { InjectionToken } from '@angular/core';

import { Observable } from 'rxjs';

export class HeadersInterceptor implements HttpInterceptor {
	intercept(req: HttpRequest<any>, next: HttpHandler) {
		const jsonApiReq = req.clone({
			headers: req.headers.set('Content-Type', 'application/vnd.api+json')
		});
		return next.handle(jsonApiReq);
	}
}

export const jsonApiInterceptor = { provide: HTTP_INTERCEPTORS, useClass: HeadersInterceptor, multi: true };

result-matching ""

    No results matching ""