Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajax-manager

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajax-manager - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

package.json
{
"name": "ajax-manager",
"version": "1.0.4",
"version": "1.0.5",
"description": "An jQuery ajax management tool",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -88,3 +88,3 @@ # ajax-manager

You can write config in both model difinition config, `ajaxManager(m, globalConfig, j)` and `API(config)`.You can find all the accepted config in [jQuery.ajax](http://api.jquery.com/jQuery.ajax/). All the config will be merged in one object just like `Object.assign(ajaxManagerConfig, modelDifinitionConfig, apiCallingConfig)` except events.
You can write config in both model difinition config, `ajaxManager(m, globalConfig, j)` and `API(config)`.You can find all the accepted config in [jQuery.ajax](http://api.jquery.com/jQuery.ajax/). All the config will be merged in one object just like `Object.assign(globalConfig, modelConfig, apiCallingConfig)` except events and `data`.

@@ -115,4 +115,69 @@ ## Events

## `Data`
All the `data` field in those 3 configs will merge into an object(Just like `Object.assign(globalConfigData, modelConfigData, apiCallingConfigData)`) insteadof cover one by one.
```javascript
var userModels = {
getUsers: {
methods: 'GET',
url: 'http://127.0.0.1/get_users',
data: {
origin: 'user'
}
}
}
var globalConfig = {
data: {
type: 'app'
}
}
var apis = ajaxManager([userModels], globalConfig, $)
api.getUsers({
data: {
auth: '123456abcdef'
}
}, true, true)
// finally when fire ajax, the data will be
/*
{
origin: 'user',
type: 'app',
auth: '123456abcdef'
}
*/
```
## `__apiRoot`
Use `__apiRoot` field to indicate the backend api root, it will concat in front of the `url`. GlobalConfig, modelConfig and apiCallingConfig are all accept this field.
```javascript
var userModels = {
getUsers: {
methods: 'GET',
url: '/get_users',
},
getUserInfoById: {
methods: 'GET',
url: '/get_user_info_by_id'
}
}
var globalConfig = {
__apiRoot: 'http://192.168.0.1'
}
var apis = ajaxManager([userModels], globalConfig, $)
api.getUsers({
data: {
auth: '123456abcdef'
}
}, true, true)
// finally when fire ajax, the url will be 'http://192.168.0.1/get_users' and 'http://192.168.0.1/get_user_info_by_id'
```
# TODO LIST:
* useage examples
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc