Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Injectable } from '@angular/core';
import { Autoregister, Service, Resource, DocumentCollection, DocumentResource } from 'ngx-jsonapi';
import { Author } from '../authors/authors.service';
import { Photo } from '../photos/photos.service';
export class Book extends Resource {
public attributes = {
date_published: '',
title: '',
created_at: '',
updated_at: ''
};
public relationships = {
author: new DocumentResource(),
photos: new DocumentCollection()
};
}
@Injectable()
export class BooksService extends Service {
public resource = Book;
public type = 'books';
public ttl = 1;
// executed before get data from server
public parseFromServer(attributes): void {
attributes.title = '📖 ' + attributes.title;
}
// executed before send to server