amplify
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/amplify package

0.0.11 • Public • Published

Amplify is a wrapper around the NodeJS http packages to help make calls easier. It is modeled after AmplifyJS. The idea is that you can use this package on the server side and AmplifyJS on the client side.

Build Status

Getting Started

Install the package

npm install amplify

Require the package

var amplify = require("amplify");

Next, define the services that you will be using

request.define('exampleService', 'ajax', {
  url: 'http://localhost:3000/service',
  dataType: 'json',
  type: 'POST'
});

Lastly, call your service

request({
  resourceId: 'exampleService',
  data: {
    name: 'example',
    anotherProperty: 'another example property'
  },
  success: function(data, status) {
    // success actions go here
  }
  error: function(error, status) {
    // error actions go here
  }
});

Request

This function is intended to make all the requests to the resources.

amplify.request(string resourceId, [hash data], [function callback])

amplify.request(hash settings)

Settings

resourceId: The identifier of the resource
data: The data to be sent
success: The success callback after the request
error: The error callback after the request

Define

Define will take care adding resources that can be used by the request.

amplify.request.define(string resourceId, string type, [hash settings])

Settings

url: The url used for the request
dataType: The content-type that is sent and received
type: The HTTP method that will be used

Readme

Keywords

none

Package Sidebar

Install

npm i amplify

Weekly Downloads

2,739

Version

0.0.11

License

MIT

Last publish

Collaborators

  • chafnan