In this example, we will be updating the application id (configurator Id) for certain model
- fetch entity data
const myHeaders = new Headers();
myHeaders.append("x-token", token);
myHeaders.append("x-lang", "uk");
const requestOptions = {
method: "GET",
headers: myHeaders,
};
const {data: entityData} = await fetch("https://example.com/api/entities/3265", requestOptions)
.then((response) => response.json())
.catch((error) => console.error(error));
- update data
const myHeaders2 = new Headers();
myHeaders2.append("x-token", token);
myHeaders2.append("Content-Type", "application/json");
entityData.configurationAppId = 1;
const raw = JSON.stringify(entityData);
const requestOptions2 = {
method: "PUT",
headers: myHeaders2,
body: raw,
};
fetch("https://example.com/api/entities/3265", requestOptions2)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));