Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wolfchamane/amjs-ajax-url
Object URL for any AJAX request
https://github.com/wolfchamane/amjs-ajax-url
ajax cjs nodejs url
Last synced: about 1 month ago
JSON representation
Object URL for any AJAX request
- Host: GitHub
- URL: https://github.com/wolfchamane/amjs-ajax-url
- Owner: Wolfchamane
- License: mit
- Created: 2019-07-02T07:26:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:00:11.000Z (almost 2 years ago)
- Last Synced: 2024-02-28T11:48:14.104Z (10 months ago)
- Topics: ajax, cjs, nodejs, url
- Language: JavaScript
- Size: 664 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @amjs/ajax-url 0.1.4
![Statements](https://img.shields.io/badge/Statements-100%25-brightgreen.svg) ![Branches](https://img.shields.io/badge/Branches-100%25-brightgreen.svg) ![Functions](https://img.shields.io/badge/Functions-100%25-brightgreen.svg) ![Lines](https://img.shields.io/badge/Lines-100%25-brightgreen.svg)
> Object URL for any AJAX request
## Installation
```bash
$ npm i @amjs/ajax-url
```
## Usage```javascript
const AmjsAjaxURL = require('@amjs/ajax-url');
const url = new AmjsAjaxURL({
domain : 'some-domain',
port : 3000,
path : 'some-path/{id}',
params : {
id : 1,
key: 'value'
}
});
console.log(url.value); // 'https://some-domain:3000/some-path/1?key=value'
```In order to use not secure protocol (http), set the 'unsecure' property to true
```javascript
const AmjsAjaxURL = require('@amjs/ajax-url');
const url = new AmjsAjaxURL({
domain : 'some-domain',
port : 3000,
path : 'some-path/{id}',
params : {
id : 1,
key : 'value'
},
unsecure : true
});
console.log(url.value); // 'http://some-domain:3000/some-path/1?key=value'
```Also you can add values assigning direct value:
```javascript
const AmjsAjaxURL = require('@amjs/ajax-url');
const url = new AmjsAjaxURL();
url.value = {
domain : 'some-domain',
port : 3000,
path : 'some-path/{id}',
params : {
id : 1,
key : 'value'
},
unsecure : true
});
console.log(url.value); // 'http://some-domain:3000/some-path/1?key=value'
```