Code Monkey home page Code Monkey logo

thesmiths-widgets.ts.httprequest's Introduction

HTTPRequest Titanium Alloy License

This module for the Appcelerator Titanium Alloy MVC framework is built on the top of the Titanium HTTPClient. It provides simple abstractions and methods to common HTTP operations.

The module defines some shortcut to quickly set headers or data for a request. Also, it will automatically parse the response and return a JSON object if the corresponding header is application/json.

Quick Start

Get it gitTio

Download this repository and install it

  • In your application's tiapp.xml file, add the module to the modules section:
<modules>
    <module platform="commonjs">ts.httprequest</module>
</modules>
  • Copy the ts.httprequest-commonjs-x.x.x.zip bundle into your root app directory.

Or use your favorite package manager

  • gitTio: gittio install ts.httprequest

Use it

var HTTPRequest = require('ts.httprequest');

var request = new HTTPRequest({
    method: 'POST',
    url: 'http://www.url.com'
    data: {
        key: 'value'
    },
    headers: {
        key: 'value'
    },
    progress: progressHandler
}).then(handleSuccess).catch(handleError);

API

new HTTPRequest(config) :: Promise

Create a new request ready to be sent

  • {Object} config Config object with the following properties:

    • {String} config.url URL to reach with the request
    • {String} [config.method="GET"] defines method (POST, GET, PUT, DELETE)
    • {Object} [config.headers={}] defines request's headers
    • {Object} [config.data={}] defines request's data
    • {Number} [config.timeout=10000] defines request's timeout (ms)
    • {Function} config.progress progress callback
  • return {Promise} A Promise resolved with the request response (formatted)

Changelog

  • 1.4 Upgrade

    • An es6-promise is now returned by the constructor
    • A progress option is now available as a callback to handle progress
  • 1.3 Upgrade

    • Mainly fixes and refactor in the code
    • Remove the dependency to underscore
  • 1.0 First version

wearesmiths

Appcelerator, Appcelerator Titanium and associated marks and logos are trademarks of Appcelerator, Inc.
Titanium is Copyright (c) 2008-2015 by Appcelerator, Inc. All Rights Reserved.
Titanium is licensed under the Apache Public License (Version 2).

thesmiths-widgets.ts.httprequest's People

Contributors

pierregui avatar ktorz avatar

Watchers

Brenton House 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.