1.2.2 • Published 3 years ago

@anecrow/eagle-im v1.2.2

Weekly downloads
16
License
MIT
Repository
-
Last release
3 years ago

API for Eagle image files management software

Build API for Eagle server with ES6.

Note: This package is not official. Let me know if there have issues and Welcome PR.

Usage

You can install the package as follows:

npm install @anecrow/eagle-im --save

common

Then import that module with:

import EagleAPI from "@anecrow/eagle-im"

// call a repuest

EagleAPI.item.list({ limit: 2 })
  .then((x) => x.json())
  .then((x) => console.log(x.data));

// change Eagle server path in

EagleAPI.baseURL = "<api url host>" // default is"http://localhost:41595/api/"

lower level

You may want a lower level function, to get fully control what you need to:

import FetchURL from "@anecrow/eagle-im/lib/FetchURL.js";

// call the same repuest above

let apiURL = new FetchURL("item", "list",{ limit: 2 }); // return a extend URL object
apiURL.callFetchJson().then((x) => console.log(x.data));

there has 5 param in constructor:

/**
 * @param {string} majorName - label of api type
 * @param {string} minorName - label of api function
 * @param {object} [paramData] - data of param object
 * @param {"GET"|"POST"} [method = "GET"] - type of request method
 * @param {string} [baseURL = "http://localhost:41595/api/"] - the api host
 */

// you can change api target anytime

apiURL.majorName = "item"
apiURL.minorName = "refreshPalette"
apiURL.paramData = {id:"KBKE02W8V0YWD"}
apiURL.method = "POST"
// FetchURL object sync update when those value change

// you shold change base api url with
apiURL.host

to get current api url

currentURL = apiURL.href // 

then call request with this data

apiURL.callFetch()

// it same as:

fetch("http://localhost:41595/api/item/refreshPalette", {
  method: "POST",
  body: JSON.stringify({id: "KBKE02W8V0YWD" })
});

there is a quick call to parse response json

apiURL.callFetchJson().then((json) => console.log(json.data));

License

MIT License

1.2.2

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.2.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago