And Is there better way to get the job via firebase rest api?
This is my code:
{
"0": {
"category_id": 0,
"created_on": "Mar 29, 2024",
"description": "Dolor justo tempor duo ipsum accusam rebum gubergren erat. Elitr stet dolor vero clita labore gubergren. Kasd sed ipsum elitr clita rebum ut sea diam tempor. Sadipscing nonumy vero labore invidunt dolor sed, eirmod dolore amet aliquyam consetetur lorem, amet elitr clita et sed consetetur dolore accusam.",
"job_id": "TEL5UAVd5b3Q4jLY2aFfWs4QneMO",
"job_nature": "Full-time",
"location": "Gabrovo, Bulgaria",
"qualifications": [
"Rebum vero dolores dolores elitr",
"Elitr stet dolor vero clita labore gubergren",
"Dolor justo tempor duo ipsum accusam"
],
"salary": "$1500-$1900",
"title": "Marketing manager",
"user_id": "qDDuvTWL00N2sNXPhMy2rE0ZB8w2"
}
}
export class JobDetailComponent implements OnInit {
job = {} as Job;
constructor(
private apiService: ApiService,
private activeRoute: ActivatedRoute
) { }
ngOnInit(): void {
this.activeRoute.params.subscribe((data) => {
const id = data['jobId'];
this.apiService.getJob(id).subscribe((job) => {
this.job = job;
console.log(job)
});
});
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment.development';
import { Category } from './types/category';
import { Job } from './types/job';
@Injectable({
providedIn: 'root'
})
export class ApiService {
constructor(private http: HttpClient) { }
getCategories() {
const { apiUrl } = environment;
return this.http.get(`${apiUrl}/categories.json`);
}
getJobs() {
const { apiUrl } = environment;
return this.http.get(`${apiUrl}/jobs.json`);
}
getJob(id: string) {
const { apiUrl } = environment;
return this.http.get(`${apiUrl}/jobs.json?orderBy="job_id"&equalTo="${id}"`);
}
}
0 comments:
Post a Comment
Thanks