So I am trying to create an Angular application and the server end point sends the following information (it's created in Python).
gltf = create_gltf(vertices, trig_faces, uv)
data = b"".join(gltf.save_to_bytes())
data_size = {"size": len(data)}
log.info(f"Length of the content is {len(data)}")
response.content_type = MEDIA_GLTF
response.context = data_size
response.data = b"".join(gltf.save_to_bytes())
response.status = falcon.HTTP_200
On the client side, I have used fetch api to receive the server response. It is stated below as the following:
const data$ = new Observable(observer => {
fetch(targetUrl.toString(), { headers: { 'responseType': 'application/octet-stream' }, method: 'GET' })
.then(response => response.arrayBuffer())
.then(gltf => {
observer.next(gltf);
observer.complete();
})
.catch(err => observer.error(err));
});
let result = data$.pipe(
map(gltfAsArrayBuffer => {
let gltfObject: any = {
'componentId': componentId,
'gltfBytes': gltfAsArrayBuffer,
};
this.surfaceMeshesGltf.set(surfaceMeshKey, gltfObject);
})
);
return result;
I was wondering how do I access the context information that I am sending over from the backend on the client side (the context information in this case is the size of the data being sent).