[英]I am getting, TypeError: Node Function not defined but required and module exported? What should I do?
I am creating the backend for an app that looks up movies via OpenImdb.我正在为通过 OpenImdb 查找电影的应用程序创建后端。 This code works standalone without node but when I require jquery, then export as a module and call it via index.js it gives me an error saying that Jquery does not contain a get function.这段代码在没有节点的情况下独立工作,但是当我需要 jquery,然后作为模块导出并通过 index.js 调用它时,它给我一个错误,说 Jquery 不包含 get 函数。 I looked up many places and everyone seems to have this problem when they did not require correctly and I used https://www.npmjs.com/package/jQuery page to make sure I'm doing it right.我查了很多地方,当他们没有正确要求时,每个人似乎都有这个问题,我使用https://www.npmjs.com/package/jQuery页面来确保我做对了。 Does anyone have any suggestions as to where I'm going wrong?有没有人对我哪里出错有什么建议?
This is the snippet of code from my Model for the IMDB lookup.这是我的模型中用于 IMDB 查找的代码片段。
let $ = require('jquery'); let methods = { apikey: "MyAPIKEY" }; methods.getMovie = async function (userSearch) { return await $.get("http://www.omdbapi.com/?s=" + userSearch + "&apikey=" + this.apikey); } methods.searchByTitle = async function (Title) { let data = await $.get("http://www.omdbapi.com/?t=" + Title + "&apikey=" + this.apikey); console.log(data); return data; } exports.data = methods;
Thanks so much for any help guys!非常感谢任何帮助家伙!
Matthew R马修·R
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.