![](/img/trans.png)
[英]How to export a symbol from a webpack bundle to use in another javascript file?
[英]How to return or export result of function javascript from service file to use in another file
服务功能
export const deviceInfoRequest = async (callback) => {
var request = new DeviceInfoMessage();
var AuthToken = 'ciOiJIUzI1NiIsInR5cCI6IkpXVCJ9';
client.deviceInfo(request, {'x-authorization': AuthToken}, (err, response) => {
var dataDevicename = response.getDevicename();
var dataDeviceid = response.getDeviceid();
console.log("DeviceName==>>>>",dataDevicename);
console.log("DeviceId==>>>>",dataDeviceid);
this.callback(dataDevicename,dataDeviceid);
});
}
=======> Result of "console.log"=="DeviceName== test" and "DeviceId==>>>> 0xdeadbeef".
传记的功能
function* getDeviceInfo({ payload }) {
try {
const deviceInfoData = yield call(deviceInfoRequest, payload);
console.log("deviceInfoSagasssssssssssssssssssssss", deviceInfoData)
if (deviceInfoData.status === 200) {
yield put(showDeviceInfoAction(deviceInfoData.data));
}
} catch (error) {
}
}
=======> Result of "console.log"=="deviceInfoSagasssssssssssssssssssssss undefined"
好吧,您需要在“Sagas”函数文件中导入该函数,请尝试:
import { deviceInfoRequest } from "../PATH_TO_FUNCTION";
然后你就可以使用那个功能了。 此外,如果您想评估该功能,只需执行deviceInfoRequest()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.