-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (36 loc) · 1.06 KB
/
index.js
File metadata and controls
43 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { Requester, Validator } = require('@goplugin/external-adapter')
require("dotenv").config();
const customError = (data) => {
if (data.Response === 'Error') return true
return false
}
const customParams = {
endpoint: ['endpoint']
}
const createRequest = (input, callback) => {
const url = `https://goplugin.apidiscovery.teejlab.com/edsn/api/benchmark/endpoint_request_live?endpoint_id=YJmrh3b`
var dataString = {"fsyms": `${input.data.fsyms}`, "tsyms": `${input.data.tsyms}`};
const config = {
url,
method : "POST",
data : dataString,
}
if (process.env.API_KEY) {
config.headers = {
"api-key": process.env.API_KEY
}
}
Requester.request(config, customError)
.then(response => {
const res = {
data: {
"result": response.data[`${input.data.fsyms}`][`${input.data.tsyms}`].toString()
}
}
callback(response.status, Requester.success(input.id, res));
})
.catch(error => {
callback(500, Requester.errored(input.id, error))
})
}
module.exports.createRequest = createRequest