I've been attempting to incorporate the Google Translate API into my Redux application, but I'm encountering difficulties. I've obtained my private keys and stored them in a local file path. The example code runs perfectly fine. However, when trying to use the translate
function within my async redux thunk, the issue arises:
const projectId = '{insert my google cloud project id here}'
const keyFilename = '{insert full path to my private key here}'
const translate = new Translate({projectId, keyFilename});
export const addPairs = createAsyncThunk(
'pairs/addPairs',
async () => {
let [translations] = await translate.translate('hello world', 'en');
return translations
}
)
Each time I invoke this function with dispatch
, it consistently returns the following error:
fs.createReadStream is not a function
I'm unable to determine why this happens, despite my attempts to find solutions online. It appears that nobody has encountered a similar scenario before... Any assistance would be greatly appreciated!