Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
toiletcoin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
toiletcoin
Commits
042810a9
Commit
042810a9
authored
Aug 05, 2019
by
OuiAtichat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api
parent
f6819f29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
13 deletions
+54
-13
src/Pages/Home.js
+54
-13
No files found.
src/Pages/Home.js
View file @
042810a9
...
...
@@ -8,6 +8,7 @@ import GetDataSelection from '../components/GetDataSelection/GetDataSelection';
import
Mapbox
from
'../components/Mapbox'
;
import
axios
from
'axios'
;
import
qs
from
'qs'
;
import
moment
from
'moment'
;
const
Data
=
[
{
...
...
@@ -104,26 +105,66 @@ class Home extends Component {
currentWeight
=
async
(
ctx
=
''
,
traceback
=
'1y'
)
=>
{
// let device_id = ctx.device_id;
const
query_generator
=
(
device_id
,
range
,
endtime
)
=>
{
// var mls = ms('1s');
let
now
=
endtime
?
endtime
:
new
Date
().
getTime
();
let
q_data
=
{
start_absolute
:
now
,
end_absolute
:
now
,
metrics
:
[
{
name
:
device_id
,
group_by
:
[
{
name
:
'tag'
,
tags
:
[
'attr'
],
},
],
tags
:
{
attr
:
[
'a12'
],
},
aggregators
:
[
{
name
:
'avg'
,
sampling
:
{
value
:
1000
,
unit
:
'milliseconds'
,
},
},
],
},
],
};
return
q_data
;
};
let
device_id
=
'3d2951a5-fa10-4d56-abae-bc471f3d2e1f'
;
let
q_data
=
qs
.
stringify
({
device_id
,
traceback
});
// let q_data = qs.stringify({ device_id, traceback });
let
q_data
=
query_generator
(
device_id
,
traceback
);
console
.
log
(
q_data
);
const
userToken
=
'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdHgiOnsib3duZXIiOiJVNDY0NzAxMzI2MjYwIn0sInNjb3BlIjpbXSwiaWF0IjoxNTY0OTc3MTY4LCJuYmYiOjE1NjQ5NzcxNjgsImV4cCI6MTYyODE0NDg5MSwiZXhwaXJlSW4iOjYzMTY3NzIzLCJqdGkiOiI3QzRNNUY1VyIsImlzcyI6ImNlcjp1c2VydG9rZW4ifQ.B0zXLSlsUucj4ohvH4lNVectCAt4hk--qMPEv-qhCUu82puCnNMsK2ZnnPeO_KE3up-vqVsjMVxLQ2jvmuspNg'
;
const
kairos_url
=
'https://feed.nexpie.io/api/v1/datapoints/query'
;
const
options
=
{
url
:
kairos_url
,
medthod
:
'get'
,
headers
:
{
'Content-Type'
:
'application/json'
},
data
:
q_data
,
auth
:
{
username
:
userToken
,
password
:
''
,
},
};
// const options = {
// url: kairos_url,
// medthod: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// // Authorization: 'Bearer ' + userToken,
// },
// data: q_data,
// // data: q_data,
// auth: {
// username: userToken,
// password: '',
// },
// };
try
{
// const response = await axios.post(kairos_url, options
);
const
response
=
await
axios
(
options
);
const
response
=
await
axios
.
post
(
kairos_url
,
q_data
);
//
const response = await axios(options);
console
.
log
(
response
);
}
catch
(
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment