简体   繁体   English

我得到了,TypeError: Node Function not defined 但需要和模块导出? 我该怎么办?

[英]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

jQuery is not meant to be used in a Node.js environment. jQuery 不打算在 Node.js 环境中使用。 For fetching data in Node trying using Got .用于在 Node 中尝试使用Got获取数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我收到此错误:声明&#39;<MODULE> &#39; 在本地,但不会导出 - Why I am getting this error: declares '<MODULE>' locally, but it is not exported 我应该如何处理“TypeError: store.addListener is not a function”错误 - What should i do with "TypeError: store.addListener is not a function" error 如何将参数传递给自我执行的module.exported匿名节点函数? - How do I pass arguments to a self-executing module.exported anonymous node function? 为什么我收到TypeError X不是函数 - Why am I getting TypeError X is not a function 我收到TypeError说forEach不是函数吗? - I am getting TypeError saying forEach is not a function? 我得到 TypeError is not a function in nodeJS - I am getting TypeError is not a function in nodeJS JavaScript TypeError,无法读取未定义的属性,但函数已定义。 我究竟做错了什么? - JavaScript TypeError, Cannot read property of undefined, but the function is defined. What am I doing wrong? 我所在的功能未定义 - The function I am in is not defined 我收到未处理的拒绝(TypeError):router.transitionTo不是一个函数。 有什么可能是错的吗? - I am getting Unhandled Rejection (TypeError): router.transitionTo is not a function. What could possibly be wrong? 我收到此错误:“TypeError:回调不是函数”,但 function 仍在执行 - I am getting this error: 'TypeError: callback is not a function', but the function is still executing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM