Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.

anecrow/eagle-im

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API of Eagle image files management software

Build API of Eagle with ES6.

Note: This package is not official. Let me know if there have issues and Wellcome 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

About

API of Eagle image files management.

Resources

License

Stars

Watchers

Forks

Packages

No packages published