Gopalakrishnan Iyer
Gopalakrishnan Iyer

Reputation: 23

How to import axios module into Alexa Node js Code in alexa skills. I am using alexa skills

How to import axios module into Alexa Node js Code within alexa skills. I am using alexa skills kit to develop a node js code. please help

Upvotes: 0

Views: 720

Answers (1)

6be709c0
6be709c0

Reputation: 8441

If you use Alexa hosted, simply reference your module in your package.json

{
  "name": "hello-world",
  "version": "1.1.0",
  "description": "alexa utility for quickly building skills",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Test",
  "license": "ISC",
  "dependencies": {
    "ask-sdk": "^2.6.0",
    "ask-sdk-core": "^2.6.0",
    "ask-sdk-dynamodb-persistence-adapter": "^2.10.2",
    "ask-sdk-model": "^1.18.0",
    "aws-sdk": "2.637.0",
    "axios": "^0.21.1",
    "i18next": "^20.3.1",
    "moment-timezone": "^0.5.33"
  },
  "devDependencies": {
    "eslint": "^7.29.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-standard": "^16.0.3",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-promise": "^5.1.0",
    "prettier": "^2.3.1"
  }
}

Then in your code, use it as usual

const axios = require("axios");

...
await axios...(...);
...

Upvotes: 1

Related Questions