yukashima huksay
yukashima huksay

Reputation: 6238

where do I install axios in nativescript-vue app?

I have two package.json files. One at the root of my project and another one in the app directoty(where the vue files are) I'm confused about which one I should use for installing axios. I would also like to know what purpose do each of these serve, which packages should be installed to which one?

Upvotes: 2

Views: 984

Answers (3)

Narendra
Narendra

Reputation: 4574

You should add at the package.json at the root level. The package.json at the root is used to define the dependencies of the template, to persist some project specific information e.g. version, scripts, hooks etc.

The package.json in the app folder serves several other purposes:

Most important - this package.json(inside app one) defines the entry point of the application (e.g "main": "main.js" or "main": "main.ns.js", ). At runtime this value is read and application is started from this point.

Here is an example of package.json inside app folder.

{
  "android": {
    "v8Flags": "--expose_gc"
  },
  "main": "main.ns.js",
  "name": "migration-ng",
  "version": "4.1.0"
}

Upvotes: 2

package.json file at root lvl just add

"axios": "^0.18.0",

Upvotes: 0

Pash
Pash

Reputation: 382

Narendara is right install in package.json and use it like this

import axios from "axios/dist/axios";

axios.get(`domain`).then(response => {});```

Upvotes: 2

Related Questions