Skip to content
/ Rest.ts Public

Rest.ts turns your Typescript class into a HTTP API

Notifications You must be signed in to change notification settings

netdur/Rest.ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

This is an example on how to implement Facebook Graph API

https://developers.facebook.com/docs/graph-api/using-graph-api

First create Facebook class implementing Service interface then create abstract[!] methods you wish to use

class Facebook implements Service {
    baseUrl = "https://graph.facebook.com"
    
    @GET(u`/me/photos`)
    myPhotos(): any {}
    
    @GET(u`/${0}?fields=comments.order(reverse_chronological)`)
    photo(photoId: number): any {}
}

and that's all, here how to use Facebook class

const fb = new Facebook();
const myPhotos = await fb.myPhotos();
const rndPhoto = await fb.photo(1);
// or 
fb.photo(1).then((r) => r.json()).then(...)

License

GPL v2

About

Rest.ts turns your Typescript class into a HTTP API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published