Resolve file path in Ionic React

Hi all,

I’m migrating codes from Hyperledger Fabric’s client to a mobile app. The original code base is in node.js written in typescript using libraries design for PCs.
Here’s a snippet of the code:

import * as grpc from '@grpc/grpc-js';
import { connect, Contract, Identity, Signer, signers } from '@hyperledger/fabric-gateway';
import * as crypto from 'crypto';
import { promises as fs } from 'fs';
import * as path from 'path';
import { TextDecoder } from 'util';

const channelName = envOrDefault('CHANNEL_NAME', 'mychannel');
const chaincodeName = envOrDefault('CHAINCODE_NAME', 'basic');
const mspId = envOrDefault('MSP_ID', 'Org1MSP');

// Path to crypto materials.
const cryptoPath = envOrDefault('CRYPTO_PATH', path.resolve(__dirname, '..', '..', '..', 'test-network', 'organizations', 'peerOrganizations', ''));

function envOrDefault(key: string, defaultValue: string): string {
    return process.env[key] || defaultValue;

A problem the I can’t seem to solve is the calling of the path.resolve() function. It seems to be designed for servers and not for mobile apps. What approach should I take to make it work on Ionic React? Thanks!

Another approach would be to read file from assets/ directory using fetch(), here’s a code snippet on doing so:

const something = await fetch('./assets/mockdata/example.text');

I can’t seem to read the text file as it returns the response below:

Response {type: 'basic', url: '', redirected: false, status: 200, ok: true, …}
body: (...)
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "basic"
url: ""
[[Prototype]]: Response