I am trying to use AWS IoT Device SDK JS 2 with a simple ReactJS application.
The application is targeted to run in a browser.
I have all the required certificates and credentials with me to configure the application.
I have below sample code to create MQTT connection:
import { iot } from 'aws-iot-device-sdk-v2';
import React, { useState } from 'react';
function App() {
try {
const config = iot.AwsIotMqttConnectionConfigBuilder.newDirectMqttBuilderWithMtlsFromPath(
'endpoint',
'device.pem.crt',
'private.pem.key'
);
.. Rest of the code ..
When I build and run this code I am getting below error in browser console.
TypeError: aws_iot_device_sdk_v2__WEBPACK_IMPORTED_MODULE_0__.iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path is not a function
Is there any issue the way I am trying to access the APIs from iot or webpack is causing this issue?