SnappFr / react-native-image-base64

Simple react native library to convert an image to a base64 string 🌄
MIT License
49 stars 28 forks source link

What is my error? TypeError: null is not an object #22

Open ved08 opened 4 years ago

ved08 commented 4 years ago

This is my code:

import ImgToBase64 from 'react-native-image-base64';
sendData = async (uri) => {
  ImgToBase64.getBase64String(uri)
      .then(base64String => {
        console.log(base64String)
      })
      .catch(err => console.log("Error Occured", err));
}

someFunction = async () => {
...function content...
this.sendData(result.uri) //here result.uri is the path to that image i.e file://...
}

With this, I am getting an error saying "TypeError: null is not an object". Please solve my error Thanks!

dylancl commented 2 years ago

Same

0x1h commented 2 years ago

same error

React-native: v0.64.3 react-native-image-base64: v0.1.4 expo: ~44.0.0

[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeImageBase.default.getBase64String')]
iamtheretronerd commented 2 years ago

same any solution ?

0x1h commented 2 years ago

@iamtheretronerd I didn't find any solution for react-native-image-base64 but you can use expo-file-system

import * as FileSystem from 'expo-file-system';

const getBase64 = async (path) => {
   await FileSystem.readAsStringAsync(path, { encoding: 'base64' })
    .then(base64 => console.log(base44))
    .catch(err => console.log(err))
}
BekaBerua commented 2 years ago

this guy is fucking right trust him ( in my opinion )