-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateVehicle.js
More file actions
executable file
·42 lines (41 loc) · 917 Bytes
/
createVehicle.js
File metadata and controls
executable file
·42 lines (41 loc) · 917 Bytes
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
#!/usr/bin/env node
const fetch = require("node-fetch")
const data = require("./data/vehicleInputExample.json")
const endpoint = process.env.ENDPOINT || "https://dev.backend.impargo.eu/"
const TOKEN = process.env.TOKEN
const query = `
mutation CreateCostprofilesVehicle($data: CostprofilesVehicleInput!) {
createCostprofilesVehicle(data: $data) {
_id
costsPerDistance
costsPerTime
name
profileType
licensePlate
weight
axis
euronorm
co2EmissionClass
fuelType
}
}
`
fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"authorization": TOKEN
},
body: JSON.stringify({
query: query,
variables: {
data,
},
})
})
.then(result => {
return result.json();
})
.then(result => {
console.log("Vehicle successfully created:\n", JSON.stringify(result.data, null, 2));
});