0

When I pass the data from node server to front-end (angular 9), I faced the problem. I made the server side using node and called data from google sheet api. I tried to get the data from node server to angular and searched on google, but I couldn't find the result.

Here is my code of node server for calling data from 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();

In this case, I am not sure how can I pass data of server to angular front-end?

I followed to lots of stackoverflows, but couldn't get them.

Bellow links were I followed.

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()

Please let me know how can I get the data from server into my frontend?

Thanks

Yelena
  • 13
  • 1
  • 6

1 Answers1

0

If you are using node, the simplest way would be to create an express js api and return the information in an endpoint, though i recommend you learn some basic concepts about APIs and client\server http communication before you start your implementation

user-ic
  • 48
  • 5
  • thanks for your advice. yeah, i already used express and node for that. my problem is to get data from it to my angular html. – Yelena Jul 10 '20 at 19:25
  • it really depends on your frontend code. this the docs reference: https://angular.io/guide/http you need to make an http request from your angular app – user-ic Jul 13 '20 at 09:01