added getTenantProperty helper
This commit is contained in:
parent
072325ad0e
commit
b4a31c76ca
@ -12,3 +12,41 @@ export function getAuthKeyFromProperties(props) {
|
||||
}
|
||||
return authKey;
|
||||
}
|
||||
|
||||
export function getTenantProperty(key, props) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!props) {
|
||||
reject("no props provided for authentication");
|
||||
return;
|
||||
}
|
||||
if (!key || key.length == 0) {
|
||||
reject("no key provided");
|
||||
return;
|
||||
}
|
||||
|
||||
var authKey = getAuthKeyFromProperties(props);
|
||||
console.log(`Fetching TPS Property [${key}]`);
|
||||
fetch(
|
||||
`${
|
||||
import.meta.env.VITE_EO_SERVICES_URL
|
||||
}/api/tps?propertyName=${key}&authKey=${authKey}`,
|
||||
{
|
||||
credentials: "include", // fetch won't send cookies unless you set credentials
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
// check for error response
|
||||
if (!response.ok) {
|
||||
reject(response.data || response.statusText);
|
||||
}
|
||||
response.json().then((data) => {
|
||||
console.log("Found Property:" + JSON.stringify(data));
|
||||
resolve(data.data.value);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user