Giter Site home page Giter Site logo

rosepriya-jk / grapp-rest-resource Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grappendorf/grapp-rest-resource

0.0 1.0 0.0 109 KB

A web component that encapsulates REST API calls

License: MIT License

JavaScript 20.73% HTML 57.45% CoffeeScript 21.83%

grapp-rest-resource's Introduction

grapp-rest-resource

A web component that encapsulates REST API calls.

Attributes

  • url

    • type: string

    A pattern for the REST URL. Can contain colon-parameters and data bindings, for example:

    url="/users/:userId?q={{searchText}}"

    Default URLS:

    Method HTTP method URL
    index GET /users
    show GET /users/1
    new GET /users/new
    create POST /users
    update PUT /users
    delete DELETE /users/1
    member foo PUT /users/1/foo
  • params

    • type: hash

    A hash that binds URL parameters to actual values, for example:

    params='{{ {"userId":user.id} }}'

  • resource

    • type: object binding

    Bind the REST ressource object to an object that can be passed around.

  • indexUrl

    • type: string

    Use this URL instead of the default one for "GET /resources" requests.

  • showUrl

    • type: string

    Use this URL instead of the default one for "GET /resources/:id" requests.

  • newUrl

    • type: string

    Use this URL instead of the default one for "GET /resources/:id" requests.

  • createUrl

    • type: string

    Use this URL instead of the default one for "POST /resources" requests.

  • updateUrl

    • type: string

    Use this URL instead of the default one for "PUT /resources/:id" requests.

  • deleteUrl

    • type: string

    Use this URL instead of the default one for "DELETE /resources/:id" requests.

  • memberUrl

    • type: string

    Use this URL instead of the default one for "PUT /resources/:id/action" requests.

Events

  • grapp-authentication-error

    Is fired when a REST API call returns a 401 error.

Resource Object methods

  • index(successCallback, errorCallback)

    Performs a HTTP GET on the index URL and returns the response data.

  • show(id, successCallback, errorCallback)

    Performs a HTTP GET on the show URL with the specified resource id and returns the response data.

  • new(successCallback, errorCallback)

    Performs a HTTP GET on the new URL and returns the response data.

  • create(data, successCallback, errorCallback)

    Performs a HTTP POST on the create URL with the specified resource data and returns the response data.

  • update(id, data, successCallback, errorCallback)

    Performs a HTTP PUT on the update URL with the specified resource id and data and returns the response data.

  • delete(id, successCallback, errorCallback)

    Performs a HTTP DELETE on the delete URL with the specified resource id and returns the response data.

  • memberAction(id, action, successCallback, errorCallback)

    Performs a HTTP PUT on the member URL with "/action" appended to it and the specified resource id and returns the response data.

grapp-rest-resource's People

Contributors

grappendorf avatar

Watchers

Rosepriya J Kannath avatar

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.