0

I am creating a new application and I want to parse an array into a "json" file in ionic 3 but it says ERROR TypeError: Object(...) is not a function; What can I do to solve this problem?

if(this.file) {
  console.log(this.userJsonUrl);
  this.file.writeFile(this.file.dataDirectory, "users.json", "Hello world",
    { replace: true }).then(done => alert('ok')).catch(err => alert('ok'))
  console.log('File created')
}

and this is the full error

ERROR TypeError: Object(...) is not a function at File.get [as dataDirectory] (index.js:649)
at RegisterPage.webpackJsonp.204.RegisterPage.register (register.ts:62)
at Object.eval [as handleEvent] (RegisterPage.ngfactory.js:116)
at Object.handleEvent (core.es5.js:12023)
at Object.handleEvent (core.es5.js:12756)
at dispatchEvent (core.es5.js:8615)
at core.es5.js:9226
at HTMLButtonElement. (platform-browser.es5.js:2651)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.es5.js:3881)

3
  • can you provide the code? Commented Apr 26, 2019 at 16:27
  • 1
    show your code. How we can help you without it? Commented Apr 26, 2019 at 16:27
  • i'm sorry its my first post ... Commented Apr 26, 2019 at 16:48

1 Answer 1

1

This error is related to @ionic-native/file.

If you install @ionic-native/file using npm install --save @ionic-native/file uninstall it using npm uninstall --save @ionic-native/file.

As your app is using Ionic 3, you should install @ionic-native/file with @4.

npm install --save @ionic-native/file@4

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.