Please provide the following:
- SDK Version: 41
- Platforms(Android/iOS/web/all): Android
- Add the appropriate “Tag” based on what Expo library you have a question on.
Hi, I’m still new to this so please correct me if I’m wrong. I was trying to get the json object from database then write it into csv file but I not sure if I’m doing it correctly because it doesn’t show where the file has saved to and I couldn’t find it. When I try to use readAsStringAsync() it says [Unhandled promise rejection: Error: No resource found with the name test123.csv]
Please help me out thanks in advance.
CSV=async(csv)=>{
var data = this.state.results
var headers = 'Transaction ID, Title, Amount, Category, Note, Date'
var csv = `${headers}${data}`;
const dir = FileSystem.documentDirectory + 'Expense Report/';
console.log(dir)
const path = dir + 'test123.csv';
await FileSystem.makeDirectoryAsync(dir, { intermediates: true });
console.log('directory check ok, writing...');
await FileSystem.writeAsStringAsync(path,csv,{ encoding: FileSystem.EncodingType.UTF8 })
await FileSystem.readAsStringAsync('test123.csv')
console.log(`wrote file ${path}`);
}