Meteor 应用程序 - 对象出现在终端中,但 DATA 在客户端出现未定义
Meteor application - object appears in the terminal, but DATA appears undefined on the client side
import { Meteor } from 'meteor/meteor';
Meteor.methods({
'harmonized'(text){
HTTP.call( 'GET', 'https://hts.usitc.gov/api/search', { params: {
"query": text
}}, function( error, response ) {
if ( error ) {
console.log( error );
} else {
return response.data.results;
}
});
}
});
以上代码为我提供了终端中的对象数组
import './shipping_steps.html';
import { HTTP } from 'meteor/http'
Template.shipping_steps.events({
// data: [],
'submit .hs': function(){
event.preventDefault();
//get Input value
const target = event.target;
const text = target.search.value;
//clear the form
target.search.value = "";
const data = Meteor.call('harmonized', text);
console.log(data);
return false;
}
})
当我尝试在客户端存储对象数组时,我没有
能够这样做并且客户端注销为未定义。然而,对于这个
代码,它正在从客户端的输入字段中获取信息
您的代码数据尚未返回值。您需要将结果存储在反应变量或会话变量上。
import { Meteor } from 'meteor/meteor';
Meteor.methods({
'harmonized'(text){
HTTP.call( 'GET', 'https://hts.usitc.gov/api/search', { params: {
"query": text
}}, function( error, response ) {
if ( error ) {
console.log( error );
} else {
return response.data.results;
}
});
}
});
以上代码为我提供了终端中的对象数组
import './shipping_steps.html';
import { HTTP } from 'meteor/http'
Template.shipping_steps.events({
// data: [],
'submit .hs': function(){
event.preventDefault();
//get Input value
const target = event.target;
const text = target.search.value;
//clear the form
target.search.value = "";
const data = Meteor.call('harmonized', text);
console.log(data);
return false;
}
})
当我尝试在客户端存储对象数组时,我没有 能够这样做并且客户端注销为未定义。然而,对于这个 代码,它正在从客户端的输入字段中获取信息
您的代码数据尚未返回值。您需要将结果存储在反应变量或会话变量上。