How to import a single order
Import individual orders seamlessly to simplify your order management.
- NodeJS
const fetch = require("node-fetch");
const endpoint = "https://backend.impargo.eu/";
const TOKEN = process.env.TOKEN;
const query = `
mutation importOrder($data: OrderImportInput!) {
importOrder(data: $data) {
_id
order {
reference
route {
distance
time
}
}
}
}
`;
fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"authorization": TOKEN,
},
body: JSON.stringify({
query: query,
variables: {
data: {
stops: [
{
location: {
city: "Budapest 5",
zipcode: "060941",
streetAndHouseNumber: "Sectorul 6",
country: "ro",
coordinates: { lon: 26.0342, lat: 44.43654 }
}
},
{
location: {
city: "Genk",
zipcode: "3600",
streetAndHouseNumber: "Avenue Albert 6",
country: "be",
coordinates: { lon: 5.49901, lat: 50.96359 }
}
}
],
},
},
}),
})
.then((result) => result.json())
.then((result) => {
console.log("Order successfully created:
", JSON.stringify(result, null, 2));
})
.catch((error) => {
console.error("Error creating order:", error);
});
- Response
{
"data": {
"importOrder": {
"_id": "6735fdf0852200cf9b0492a2",
"order": {
"reference": "1411 / DE 10117 - FR 75001",
"route": {
"distance": 1055.74,
"time": 13.1475
}
}
}
}
}