【发布时间】:2020-10-30 22:33:24
【问题描述】:
当我将数据从节点服务器传递到前端(角度 9)时,我遇到了问题。 我使用节点制作服务器端并从谷歌表 api 调用数据。 我试图从节点服务器获取数据到角度并在谷歌上搜索,但我找不到结果。
这是我的节点服务器代码,用于从 googlesheet 调用数据。
const doc = new GoogleSpreadsheet('1w0aEvmo8H-PPMQEaYWEfN8QSoeGgAKIb9gA0fr4V9VM');
async function accessSpreadSheet() {
await doc.useServiceAccountAuth({
client_email: creds.client_email,
private_key: creds.private_key,
});
await doc.loadInfo(); // loads document properties and worksheets
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
console.log(sheet.title);
console.log(sheet.rowCount);
}
accessSpreadSheet();
在这种情况下,我不确定如何将服务器的数据传递给 Angular 前端?
我关注了很多 stackoverflow,但无法获得它们。
我关注了以下链接。
How do I pass node.js server variables into my angular/html view?
How to send JSON data from node to angular 4
send data from node.js to angular with get()
请告诉我如何将数据从服务器获取到我的前端?
谢谢
【问题讨论】: