w-web-api 1.0.42 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,74 +0,0 @@
1
- import axios from 'axios'
2
- import get from 'lodash-es/get.js'
3
- import ltdtpick from 'wsemi/src/ltdtpick.mjs'
4
- import genPm from 'wsemi/src/genPm.mjs'
5
-
6
-
7
- async function provideApis(url, group, apis) {
8
- //url: 指API伺服器提供的接入網址, 例如 http://localhost:11005/syncAndReplaceApis
9
- //group: 指API所屬群組
10
-
11
- //pm
12
- let pm = genPm()
13
-
14
- //ks
15
- let ks = [
16
- 'id', //'id-for-apis-pets-guineapigs-1'
17
- 'name', //'取得天竺鼠清單資訊'
18
- 'description', //'取得天竺鼠清單資訊'
19
- 'url', //指api網址, 例如 http://localhost:11005/getDogsList
20
- 'method', //'get'
21
- 'version', //'v1'
22
- 'group', //'寵物'
23
- 'levels', //'寵物.天竺鼠'
24
- 'keywords', //'pets;guineapigs'
25
- 'state', //'ok'
26
- 'creator', //'pets-system'
27
- 'dataSource', //'pets-data'
28
- 'mdInputParams', //輸入方式說明, markdown格式
29
- 'inputExample', //輸入範例數據
30
- 'mdOutputParams', //輸出方式說明, markdown格式
31
- 'outputExample', //輸出範例數據, json格式
32
- ]
33
-
34
- //ltdtpick
35
- apis = ltdtpick(apis, ks)
36
- // console.log('apis', apis)
37
-
38
- //rin
39
- let rin = {
40
- group,
41
- apis,
42
- }
43
- // console.log('rin', rin)
44
-
45
- //axios
46
- await axios({
47
- method: 'post',
48
- url,
49
- headers: { 'Content-Type': 'application/json; charset=utf-8' },
50
- data: rin,
51
- })
52
- .then((res) => {
53
- // console.log('then', res)
54
- let data = get(res, 'data')
55
- let state = get(data, 'state')
56
- let msg = get(data, 'msg', '')
57
- if (state === 'success') {
58
- pm.resolve(msg)
59
- }
60
- else {
61
- pm.reject(msg)
62
- }
63
-
64
- })
65
- .catch((err) => {
66
- // console.log('catch', err)
67
- pm.reject(err)
68
- })
69
-
70
- return pm
71
- }
72
-
73
-
74
- export default provideApis