Skip to content
Xu,Yizhi edited this page May 27, 2015 · 2 revisions

请求数据

lark 封装了一套 promise 风格,支持 Restful API 的 http 请求库(基于got),让您能以最舒适的方式从后端服务获取数据。

简单示例如下:

var http = require('lark').http
http.get('http://host/data/1').then(function handleData(){
    // handle data process.
}).catch(function handleError(err) {
    console.error(err);
    console.log(err.response);
    console.log(err.body);
});

lark的http支持 Restful 规范要求的 get, post, put, patch, head, delete 等方式,非常适合面向服务的架构。

Clone this wiki locally