Rejected promise with error

The place to discuss development topics.
Discussions on the RICOH THETA API and SDK, image processing of spherical images, other hardware related topics, introduction of useful libraries, etc.

Rejected promise with error

Postby PaulIngram » 04 Jun 2019, 16:11

Ricoh Theta SC
FIRMWARE: Version 01.20
API: v2.1
https://developers.theta360.com/en/docs/v2.1/api_reference/commands/camera.get_live_preview.html
Endpoint: http://192.168.1.1:80/osc/commands/execute”
Request type: POST
Headers: “Content-type”: “application/json; charset=UTF-8"
Data: “{\“name\“:\“camera.getLivePreview\“,\“parameters\“:{}}”


When POSTing to this command, we receive the following headers as expected:

```multipart/x-mixed-replace; boundary=---osclivepreview---```



However, when we use the following JavaScript code to read the stream (for the mixed-replace content parts) we simply get a rejected Promise with the error


Code: Select all
```"TypeError: cancelled"```
```fetch('http://192.168.1.1:80/osc/commands/execute', {
                method: 'POST',
                headers: {
                  "Content-type": "application/json; charset=UTF-8"
                },
                body: JSON.stringify({ name: 'camera.getLivePreview', parameters: {}}),
            })
            .then(function (res) {
                console.log(res.headers.get('content-type'));
                return res.body.getReader().read().then(function processStream(readData) {
                    console.log(readData);
                    return res.body.getReader().read().then(processStream);
                });
            });```


...any help would be appreciated - thanks!
PaulIngram
 
Posts: 1
Joined: 27 Oct 2017, 09:18

Return to Development



All times are UTC