Coder Social home page Coder Social logo

angular-buch / book-monkey2-api Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 0.0 963 KB

:monkey_face: 1. Auflage: REST API backend for BookMonkey

Home Page: https://book-monkey2-api.angular-buch.com/

JavaScript 95.17% HTML 0.30% CSS 3.91% TypeScript 0.62%
backend restify typescript

book-monkey2-api's People

Contributors

d-koppenhagen avatar fmalcher avatar johanneshoppe avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

book-monkey2-api's Issues

Using TypeScript um Json auf Objekte zu "mappen"

Ich bin kürzlich auf eine einfache Methode gestoßen, um Json auf eigene Objekttypen mit dem as-Operator zu "mappen". Ganz ohne RxJS.map und Factories:
Beispiel-Json:
example.json

{
  "title": "Complexes Objekt",
  "persons": 
  [
	{
		"id": 1,
		"name": "Max"
	},
	{
		"id": 2,
		"name": "Moritz"
	},
	{
		"id": 3,
		"name": "Widow Bolte"
	}
  ],
  "actions": 
  [
	{
		"id": 1,
		"description": "saw gap into bridge"
	},
	{
		"id": 2,
		"description": "steal grilled chicken"
	}
  ],
}

example.models.ts

export class Person {
  public id: number;
  public name: string;
}

export class Action {
  public id: number;
  public description: string;
}

export class Events {
  public title: string;
  public persons: Person[];
  public actions: Action[];
}

example.services.ts

import { Person, Action, ComplexObj } from '.model.ts';
...
@Injectable()
export class exampleService {
	...
	public readAll(): Observable<Events> {
		return this.http
		  .get('/Api/AllEvents/')
		  .retry(3)
		  .map(response => response.json() as Events)
		  .catch(this.errorHandler);
	}

Die interessante Teil ist: .map(response => response.json() as Events)

example.component.ts

...
src: exampleService;
ev: Events;
constructor(@Inject(exampleService) exampleServiceFactory: any) {
	this.src = exampleServiceFactory();
}
ngOnInit(){
	this.src.readAll().subscribe(res => this.ev = res);
}

Falls ich einen entsprechenden Hinweis nicht überlesen habe, hoffe ich, dass diese eine hilfreiche Anmerkung ist.

Cross-Origin Request Blocked

Hi,

thanks for the api server! But I'm getting a "Cross-Origin Request Blocked" error when talking to your server! Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.