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

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
it really depends on your frontend code. this the docs reference: angular.io/guide/http you need to make an http request from your angular app

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.