Skip to content

Commit

Permalink
Update test.component.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
dudushy committed Apr 9, 2024
1 parent 3834735 commit 99e6863
Showing 1 changed file with 42 additions and 18 deletions.
60 changes: 42 additions & 18 deletions src/app/pages/test/test.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { AppComponent } from '../../app.component';
export class TestComponent implements OnInit {
TITLE = 'TestComponent';

baseUrl = 'https://webservice.dudushy.net/';
// baseUrl = 'https://test.dudushy.net/';
baseUrl = 'https://webservice.dudushy.net';
// baseUrl = 'https://test.dudushy.net';

dataArray: any[] = [];
mode = 'add';
Expand Down Expand Up @@ -48,12 +48,18 @@ export class TestComponent implements OnInit {
}

loadDataArray() {
const url = `${this.baseUrl}/api`;
console.log(`[${this.TITLE}#loadDataArray] url`, url);

const headers = {
'Content-Type': 'application/json'
};
console.log(`[${this.TITLE}#loadDataArray] headers`, headers);

this.app.http.get(
`${this.baseUrl}/api`,
url,
{
headers: {
'Content-Type': 'application/json'
}
headers: headers
}
).subscribe((data: any) => {
console.log(`[${this.TITLE}#loadDataArray] data`, data);
Expand Down Expand Up @@ -116,13 +122,19 @@ export class TestComponent implements OnInit {
console.log(`[${this.TITLE}#saveItem] body`, body);

if (this.mode === 'add') {
const url = `${this.baseUrl}/api/create`;
console.log(`[${this.TITLE}#saveItem] url`, url);

const headers = {
'Content-Type': 'application/json'
};
console.log(`[${this.TITLE}#saveItem] headers`, headers);

this.app.http.post(
`${this.baseUrl}/api/create`,
url,
body,
{
headers: {
'Content-Type': 'application/json'
}
headers: headers
}
).subscribe((data: any) => {
console.log(`[${this.TITLE}#saveItem] data`, data);
Expand All @@ -137,13 +149,19 @@ export class TestComponent implements OnInit {
}

if (this.mode === 'save') {
const url = `${this.baseUrl}/api/update/${this.selectedId}`;
console.log(`[${this.TITLE}#saveItem] url`, url);

const headers = {
'Content-Type': 'application/json'
};
console.log(`[${this.TITLE}#saveItem] headers`, headers);

this.app.http.put(
`${this.baseUrl}/api/update/${this.selectedId}`,
url,
body,
{
headers: {
'Content-Type': 'application/json'
}
headers: headers
}
).subscribe((data: any) => {
console.log(`[${this.TITLE}#saveItem] data`, data);
Expand Down Expand Up @@ -184,12 +202,18 @@ export class TestComponent implements OnInit {
return;
}

const url = `${this.baseUrl}/api/delete/${itemData.id}`;
console.log(`[${this.TITLE}#deleteItem] url`, url);

const headers = {
'Content-Type': 'application/json'
};
console.log(`[${this.TITLE}#deleteItem] headers`, headers);

this.app.http.delete(
`${this.baseUrl}/api/delete/${itemData.id}`,
url,
{
headers: {
'Content-Type': 'application/json'
}
headers: headers
}
).subscribe((data: any) => {
console.log(`[${this.TITLE}#deleteItem] data`, data);
Expand Down

0 comments on commit 99e6863

Please sign in to comment.