2.0.3 • Published 8 years ago

salt-fetch v2.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

salt.fetch

独立的ajax/jsonp模块。

特别说明

salt.fetch就是 nattyFetchnattyStorage 的引用合集,看源代码便知。

为什么这么做?为了给salt的使用者提供一致的开发体验,故将nattyFetch工具以fetch属性的方式集成在salt命名空间下。

安装

通过npm下载代码,目前最新版本为2.0.0

npm install salt-fetch --save

插入代码

<script src="path/to/node_modules/salt-fetch/dist/salt-fetch.js"></script>

文档

salt.fetch的特点和文档,直接见 nattyFetch 的文档即可。原文档中使用nattyFetch的地方,都可以直接使用salt.fetch替换,一模一样,如:

nattyFetch文档:

const context = nattyFetch.context({
    urlPrefix: '//example.com/api/'
});
context.create({
    getList: {
        url: 'getList.do',
        plugins: [
            nattyFetch.plugin.soon
        ]
    }
});
module.exports = context.api;

使用salt.fetch后:

const context = salt.fetch.context({ // 用`salt.fetch`替换`nattyFetch`
    urlPrefix: '//example.com/api/'
});
context.create({
    getList: {
        url: 'getList.do',
        plugins: [
            salt.fetch.plugin.soon // 用`salt.fetch`替换`nattyFetch`
        ]
    }
});
module.exports = context.api;

salt.fetchnattyFetch的不同之处:

  • salt.fetch只有移动端版本。
  • salt-fetch.js文件内置了natty-fetch.jsnatty-storage.js两个文件的内容。而natty-fetch.js没有内置natty-storage.js文件的内容。
2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0-rc4

8 years ago

1.0.0-rc3

8 years ago

1.0.0-rc1

8 years ago