5

Hello I am new to using Babel to transpile and polyfill my code to work for older browsers like Edge and IE. I am currently having an issue with polyfilling my code for Promises. I check in Edge and the error I am receiving is:

Error in created hook: "TypeError: Object doesn't support property or method 'finally'

So the issue is with the finally method in my Vue app. In my app I am using Axios to get data from an API.

So I was going through the steps here: https://babeljs.io/setup.html#installation under the CLI instructions. My package.json file currently looks like so:

{
    "name": "job-filtering",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1",
      "build": "babel src -d lib"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
      "@babel/cli": "^7.2.3",
      "@babel/core": "^7.2.2",
      "@babel/plugin-transform-regenerator": "^7.0.0",
      "@babel/preset-env": "^7.2.3"
    },
    "dependencies": {
      "@babel/polyfill": "^7.2.5"
    }
}

and my .babelrc file looks like:

{
    "presets": ["@babel/preset-env"],
    "plugins": ["@babel/plugin-transform-regenerator"]
}

and so when I use npm run build in my command line it does transpile my code for what it can, but it does not polyfill things like the finally method in my promise.

I've been trying to search to find an answer, but I can't seem to find anything that is what I'm looking for.

I tried adding:

import 'babel/polyfill';

to the top of my JS file, but that then spit out an error. I know it's probably something small that I'm missing to allow babel to polyfill my JS, but I can't seem to find a solution.

Goran Kutlaca
  • 2,014
  • 1
  • 12
  • 18
user9664977
  • 789
  • 2
  • 15
  • 28

0 Answers0