This gist shows code to create thin wrapper around browser fetch
api and call it as FetchClient
. But first lets see the usage
of GET/POST requests
- Simple get request
FetchClient(url, HttpMethod.GET);
- POST request with Form Data
/** | |
* Maps Employees to mat-table data format | |
* | |
* @author Pavan Kumar Jadda | |
* @since 1.0.0 | |
*/ | |
private mapTableData(data: UserData[]) { | |
this.dataSource = new MatTableDataSource<UserData>(data); | |
if (this.optionalParamsPresent()) { |
/** | |
* Update parameters after user enters search text or changes page selection | |
* | |
* @author Pavan Kumar Jadda | |
* @since 2.0.0 | |
*/ | |
updateRouteParameters($event: PageEvent | null) { | |
const params = { | |
pageIndex: this.paginator.pageIndex, | |
pageSize: this.paginator.pageSize, |
<mat-form-field appearance="fill"> | |
<mat-label>Filter</mat-label> | |
<input | |
[formControl]="searchTextControl" | |
matInput | |
(keyup)="applyFilter($event)" | |
placeholder="Ex. Mia" | |
#input | |
/> | |
</mat-form-field> |
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events
{
worker_connections 1024;
###### Install dependencies only when needed ######
FROM node:16-alpine AS builder
ARG CONFIGURATION='dev'
# Make /app as working directory
WORKDIR /app
# Copy package.json file
COPY package.json .
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles(value = "local")
@AutoConfigureMockMvc
@WithUserDetails(value = "jaddap2", userDetailsServiceBeanName = "customDbUserDetailsService")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PersonIntegrationTest
{
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ContextConfiguration(classes = {PresApplication.class})
@WithUserDetails(value = "demo_user", userDetailsServiceBeanName = "customDbUserDetailsService")
@AutoConfigureMockMvc
@ActiveProfiles(value = "local")
class PersonControllerTest
{
@Autowired
private MockMvc mockMvc;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles(value = "local")
@AutoConfigureMockMvc
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class EmployeeServiceTest
{
@Mock
EmployeeRepository employeeRepository;
@ExtendWith(SpringExtension.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ContextConfiguration(classes = {MyApplication.class})
@ImportAutoConfiguration(RefreshAutoConfiguration.class)
@ActiveProfiles(value = "local")
class EmployeeRepositoryTest
{
@Autowired