Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

javascript - Recognizing a variable from an NPM API in CodePen

I recently used https://www.npmjs.com/package/@freezegold/covid-19 API on VSC for use of Discord bot. It included

const virus = require('@freezegold/covid-19');

and all syntax functioned and gave me the information that I wanted. Now I want to use the same NPM on CodePen to function as website instead and when I install the exact API from their NPM installer, it shows up as this

import * as FreezegoldCovid19 from "https://cdn.skypack.dev/@freezegold/[email protected]";
virus.covid('global', (err, res) => {
  if(err) throw err
  console.log(res)
});

I am aware this new import is how ES6 works, but the error code of virus is not defined kept popping up despite me trying to figure out how to define virus, since it initially worked on my other project. Is it a syntax issue or do I need to do something else with CodePen to make this code work as it normally did using require instead of import


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...