question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Basic starting question for new user

See original GitHub issue

Hi there. I have written an App using nodejs and js. I have never used an API before.

I think I have the correct auth information now, and I’m trying to get the node_module to work, but can’t seem to get it to load.

My app is mode up of a node server, a html file, and a single js file, like this:

/server.js
/public/index.html
/public/js/script

I’ve used npm install, and I can see the google-ads-api in my /nodes_module/ folder.

I just don’t know where or how to call the node module!

Right now I’ve created /public/js/ads.js, and I’ve set it to load as type = "module" within the index.html

I have this inside:

import { GoogleAdsApi } from "/node_modules/google-ads-api";

const client = new GoogleAdsApi({
  client_id: "[my client ID]",
  client_secret: "[my client secret]",
  developer_token: "[my dev token]",
});


const refreshToken = "[my refresh token]"
const customers = await client.listAccessibleCustomers(refreshToken);`

However When loading the page, I get http://localhost:3000/node_modules/google-ads-api net::ERR_ABORTED 404 (Not Found) in the console.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
sgpascoecommented, Jan 25, 2022

Thanks so much @Zikoel ! This is exactly what I needed to hear to solve the problem, I’ll do the imports on the server side and work out how to pass the data to the client side 😃

Sorry for asking such a basic question, I’m really trying to learn backend and API related things recently, and really appreciate the help. I’m learning very fast with these practise projects.

1reaction
Zikoelcommented, Jan 24, 2022

You are trying to use this library client side! But I’m pretty sure that is almost impossibile do that! This is a library developed to be used on server side! You need to move all you logic on the server side part of your app and use te client only to show someting to the user!

More of this admitting (and is not the case) that the library is ready to be used on the client side you need to pack it and serve it the bundle on the client side with something like webpack or similar! I’m sorry but seems like that you are mossing some very basic concept about nodejs and in general webapps composed by backend and frontend!

I don’t want discorage you absolutelty but I suggest you first study the lib on server side and with a solid undertanding go further and integrate an UI. I’ve no problem to show you a minimal example!

Read more comments on GitHub >

github_iconTop Results From Across the Web

STARTER QUESTIONS FOR USER RESEARCH
The following is a list of questions that you can use throughout the customer and product development process. Asking open ended questions is...
Read more >
100 Getting to Know You Questions - SignUpGenius
Break the ice and get to know people better by selecting several of these get-to-know-you questions. Who is your hero?
Read more >
User Interview Example Questions
The following are sample questions for a user interview. Please note that your questions need to be tailored to each individual project.
Read more >
55 Top “Get to Know You" Questions for the Workplace - Indeed
Get-to-know-you questions are a good way to meet new people or introduce new teammates. · Ask thoughtful, open-ended questions to create an ...
Read more >
A Cheatsheet for User Interview and Follow Ups Questions
1. Open discovery questions · “Tell me about …” · “What is / are …?” · “What … do you use / do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found