openvidu-node-client support for Angular 6 (axios and buffer dependecies)

pull/73/head
pabloFuente 2018-06-04 14:14:17 +02:00
parent dcae9a0ac3
commit 12f300d916
6 changed files with 3295 additions and 247 deletions

View File

@ -111,7 +111,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L37">OpenVidu.ts:37</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L35">OpenVidu.ts:35</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -152,7 +152,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L53">OpenVidu.ts:53</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L51">OpenVidu.ts:51</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -181,7 +181,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L307">OpenVidu.ts:307</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L294">OpenVidu.ts:294</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -216,7 +216,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L208">OpenVidu.ts:208</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L201">OpenVidu.ts:201</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -251,7 +251,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L253">OpenVidu.ts:253</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L243">OpenVidu.ts:243</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -276,7 +276,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L66">OpenVidu.ts:66</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L64">OpenVidu.ts:64</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -307,7 +307,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L67">OpenVidu.ts:67</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L65">OpenVidu.ts:65</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -346,7 +346,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L68">OpenVidu.ts:68</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L66">OpenVidu.ts:66</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -389,7 +389,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L160">OpenVidu.ts:160</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/OpenVidu.ts#L155">OpenVidu.ts:155</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">

View File

@ -114,7 +114,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L36">Session.ts:36</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L35">Session.ts:35</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
@ -145,7 +145,7 @@
<div class="tsd-signature tsd-kind-icon">properties<span class="tsd-signature-symbol">:</span> <a href="../interfaces/sessionproperties.html" class="tsd-signature-type">SessionProperties</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L36">Session.ts:36</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L33">Session.ts:33</a></li>
</ul>
</aside>
</section>
@ -155,7 +155,7 @@
<div class="tsd-signature tsd-kind-icon">session<wbr>Id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L35">Session.ts:35</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L32">Session.ts:32</a></li>
</ul>
</aside>
</section>
@ -172,7 +172,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L58">Session.ts:58</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L57">Session.ts:57</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
@ -201,7 +201,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L49">Session.ts:49</a></li>
<li>Defined in <a href="https://github.com/OpenVidu/openvidu/tree/master/openvidu-node-client/src/Session.ts#L48">Session.ts:48</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">

3066
openvidu-node-client/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,22 +14,25 @@
"build": "tsc",
"docs": "grunt --gruntfile config/typedoc/custom-theme/gruntfile.js && typedoc --options ./config/typedoc/typedoc.js --out ./docs ./src && rm -rf ../../openvidu.io/api/openvidu-node-client/* && cp -R ./docs/. ../../openvidu.io/api/openvidu-node-client"
},
"dependencies": {},
"dependencies": {
"axios": "^0.18.0",
"buffer": "^5.1.0"
},
"devDependencies": {
"@types/node": "9.6.6",
"ts-node": "6.0.0",
"tslint": "5.9.1",
"@types/node": "10.3.0",
"ts-node": "6.1.0",
"tslint": "5.10.0",
"typedoc": "^0.11.1",
"typedoc-plugin-sourcefile-url": "^1.0.3",
"typescript": "2.8.3",
"grunt": "^1.0.1",
"grunt-autoprefixer": "^3.0.4",
"grunt-cli": "^1.2.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-uglify": "^2.3.0",
"grunt-contrib-watch": "~1.0.0",
"grunt-string-replace": "^1.0.0",
"grunt-ts": "^5.5.1"
"typescript": "2.9.1",
"grunt": "1.0.3",
"grunt-autoprefixer": "3.0.4",
"grunt-cli": "1.2.0",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-sass": "1.0.0",
"grunt-contrib-uglify": "3.3.0",
"grunt-contrib-watch": "1.1.0",
"grunt-string-replace": "1.3.1",
"grunt-ts": "6.0.0-beta.19"
}
}
}

View File

@ -21,10 +21,7 @@ import { Recording } from './Recording';
import { RecordingLayout } from './RecordingLayout';
import { RecordingProperties } from './RecordingProperties';
/**
* @hidden
*/
const https = require('https');
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
export class OpenVidu {
@ -35,6 +32,7 @@ export class OpenVidu {
private hostname: string;
private port: number;
private basicAuth: string;
private Buffer = require('buffer/').Buffer;
/**
* @param urlOpenViduServer Public accessible IP where your instance of OpenVidu Server is up an running
@ -82,19 +80,19 @@ export class OpenVidu {
public startRecording(sessionId: string, param2?: string | RecordingProperties): Promise<Recording> {
return new Promise<Recording>((resolve, reject) => {
let requestBody;
let data;
if (!!param2) {
if (!(typeof param2 === 'string')) {
const properties = <RecordingProperties>param2;
requestBody = JSON.stringify({
data = JSON.stringify({
session: sessionId,
name: !!properties.name ? properties.name : '',
recordingLayout: !!properties.recordingLayout ? properties.recordingLayout : '',
customLayout: !!properties.customLayout ? properties.customLayout : ''
});
} else {
requestBody = JSON.stringify({
data = JSON.stringify({
session: sessionId,
name: param2,
recordingLayout: '',
@ -102,7 +100,7 @@ export class OpenVidu {
});
}
} else {
requestBody = JSON.stringify({
data = JSON.stringify({
session: sessionId,
name: '',
recordingLayout: '',
@ -110,41 +108,38 @@ export class OpenVidu {
});
}
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_START,
method: 'POST',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
axios.post(
'https://' + this.hostname + ':' + this.port + OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_START,
data,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/json'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 200) {
)
.then(res => {
if (res.status === 200) {
// SUCCESS response from openvidu-server (Recording in JSON format). Resolve new Recording
resolve(new Recording(JSON.parse(body)));
resolve(new Recording(res.data));
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString()));
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(new Error(e));
});
req.write(requestBody);
req.end();
});
}
@ -160,40 +155,38 @@ export class OpenVidu {
public stopRecording(recordingId: string): Promise<Recording> {
return new Promise<Recording>((resolve, reject) => {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_STOP + '/' + recordingId,
method: 'POST',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
axios.post(
'https://' + this.hostname + ':' + this.port + OpenVidu.API_RECORDINGS + OpenVidu.API_RECORDINGS_STOP + '/' + recordingId,
undefined,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 200) {
)
.then(res => {
if (res.status === 200) {
// SUCCESS response from openvidu-server (Recording in JSON format). Resolve new Recording
resolve(new Recording(JSON.parse(body)));
resolve(new Recording(res.data));
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString()));
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(new Error(e));
});
// req.write();
req.end();
});
}
@ -208,40 +201,37 @@ export class OpenVidu {
public getRecording(recordingId: string): Promise<Recording> {
return new Promise<Recording>((resolve, reject) => {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + '/' + recordingId,
method: 'GET',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
axios.get(
'https://' + this.hostname + ':' + this.port + OpenVidu.API_RECORDINGS + '/' + recordingId,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 200) {
)
.then(res => {
if (res.status === 200) {
// SUCCESS response from openvidu-server (Recording in JSON format). Resolve new Recording
resolve(new Recording(JSON.parse(body)));
resolve(new Recording(res.data));
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString()));
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(new Error(e));
});
// req.write();
req.end();
});
}
@ -253,45 +243,42 @@ export class OpenVidu {
public listRecordings(): Promise<Recording[]> {
return new Promise<Recording[]>((resolve, reject) => {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS,
method: 'GET',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
axios.get(
'https://' + this.hostname + ':' + this.port + OpenVidu.API_RECORDINGS,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 200) {
)
.then(res => {
if (res.status === 200) {
// SUCCESS response from openvidu-server (JSON arrays of recordings in JSON format). Resolve list of new recordings
const recordingArray: Recording[] = [];
const responseItems = JSON.parse(body).items;
const responseItems = res.data.items;
for (const item of responseItems) {
recordingArray.push(new Recording(item));
}
resolve(recordingArray);
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString()));
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(new Error(e));
});
// req.write();
req.end();
});
}
@ -307,45 +294,42 @@ export class OpenVidu {
public deleteRecording(recordingId: string): Promise<Error> {
return new Promise<Error>((resolve, reject) => {
const options = {
hostname: this.hostname,
port: this.port,
path: OpenVidu.API_RECORDINGS + '/' + recordingId,
method: 'DELETE',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
axios.delete(
'https://' + this.hostname + ':' + this.port + OpenVidu.API_RECORDINGS + '/' + recordingId,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 204) {
)
.then(res => {
if (res.status === 204) {
// SUCCESS response from openvidu-server. Resolve undefined
resolve(undefined);
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString()));
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(new Error(e));
});
// req.write();
req.end();
});
}
private getBasicAuth(secret: string): string {
return 'Basic ' + (new Buffer('OPENVIDUAPP:' + secret).toString('base64'));
return 'Basic ' + this.Buffer('OPENVIDUAPP:' + secret).toString('base64');
}
private setHostnameAndPort(): void {

View File

@ -22,10 +22,7 @@ import { RecordingMode } from './RecordingMode';
import { SessionProperties } from './SessionProperties';
import { TokenOptions } from './TokenOptions';
/**
* @hidden
*/
const https = require('https');
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
export class Session {
@ -35,6 +32,8 @@ export class Session {
sessionId: string;
properties: SessionProperties;
private Buffer = require('buffer/').Buffer;
constructor(private hostname: string, private port: number, private basicAuth: string, properties?: SessionProperties) {
if (!properties) {
this.properties = {};
@ -58,47 +57,44 @@ export class Session {
public generateToken(tokenOptions?: TokenOptions): Promise<string> {
return new Promise<string>((resolve, reject) => {
const requestBody = JSON.stringify({
const data = JSON.stringify({
session: this.sessionId,
role: (!!tokenOptions && !!tokenOptions.role) ? tokenOptions.role : OpenViduRole.PUBLISHER,
data: (!!tokenOptions && !!tokenOptions.data) ? tokenOptions.data : ''
});
const options = {
hostname: this.hostname,
port: this.port,
path: Session.API_TOKENS,
method: 'POST',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
axios.post(
'https://' + this.hostname + ':' + this.port + Session.API_TOKENS,
data,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/json'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 200) {
)
.then(res => {
if (res.status === 200) {
// SUCCESS response from openvidu-server. Resolve token
const parsed = JSON.parse(body);
resolve(parsed.id);
resolve(res.data.id);
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
reject(new Error(error.response.status.toString()));
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(e);
});
req.write(requestBody);
req.end();
});
}
@ -112,7 +108,7 @@ export class Session {
resolve(this.sessionId);
}
const requestBody = JSON.stringify({
const data = JSON.stringify({
mediaMode: !!this.properties.mediaMode ? this.properties.mediaMode : MediaMode.ROUTED,
recordingMode: !!this.properties.recordingMode ? this.properties.recordingMode : RecordingMode.MANUAL,
defaultRecordingLayout: !!this.properties.defaultRecordingLayout ? this.properties.defaultRecordingLayout : RecordingLayout.BEST_FIT,
@ -120,46 +116,45 @@ export class Session {
customSessionId: !!this.properties.customSessionId ? this.properties.customSessionId : ''
});
const options = {
hostname: this.hostname,
port: this.port,
path: Session.API_SESSIONS,
method: 'POST',
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
axios.post(
'https://' + this.hostname + ':' + this.port + Session.API_SESSIONS,
data,
{
headers: {
'Authorization': this.basicAuth,
'Content-Type': 'application/json'
}
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (d) => {
// Continuously update stream with data
body += d;
});
res.on('end', () => {
if (res.statusCode === 200) {
// SUCCESS response from openvidu-server. Resolve sessionId
const parsed = JSON.parse(body);
this.sessionId = parsed.id;
resolve(parsed.id);
} else if (res.statusCode === 409) {
// 'customSessionId' already existed
this.sessionId = this.properties.customSessionId;
)
.then(res => {
if (res.status === 200) {
// SUCCESS response from openvidu-server. Resolve token
this.sessionId = res.data.id;
resolve(this.sessionId);
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.statusCode));
reject(new Error(res.status.toString()));
}
}).catch(error => {
if (error.response) {
// The request was made and the server responded with a status code (not 2xx)
if (error.response.status === 409) {
// 'customSessionId' already existed
this.sessionId = this.properties.customSessionId;
resolve(this.sessionId);
} else {
reject(new Error(error.response.status.toString()));
}
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error', error.message);
}
});
});
req.on('error', (e) => {
reject(e);
});
req.write(requestBody);
req.end();
});
}