You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i have a very sstrange problem.
The library works very well on local, but when i use it in my cloud functions, i have an error that says the Promise took too much time. The promise await forever.
Thats my code
import * as functions from "firebase-functions";
import { errors, GoogleAdsApi } from "google-ads-api";
import { GoogleAdsProductResponse } from "../../interfaces/googleAdsInterfaces";
import { getUserRefreshToken } from "../../src/userTokenManager";
const client = new GoogleAdsApi({
client_id: process.env.VITE_APP_CLIENT_ID!,
client_secret: process.env.VITE_APP_CLIENT_SECRET!,
developer_token: process.env.VITE_GOOGLEADS_DEV_TOKEN!,
});
export async function getProductsAdsInformation(
userUid: string,
customerId: string
): Promise<GoogleAdsProductResponse[] | null> {
const refreshToken = await getUserRefreshToken(userUid);
const customer = client.Customer({
customer_id: customerId,
refresh_token: refreshToken,
});
functions.logger.warn(`getProductsAdsInformation`);
let requestResponse: any = null;
try {
requestResponse = await customer
.query(
`SELECT
customer.id,
metrics.clicks,
metrics.conversions,
metrics.conversions_value,
metrics.conversions_from_interactions_rate,
metrics.impressions,
metrics.cost_micros,
metrics.ctr,
FROM shopping_performance_view `
)
} catch (err) {
if (err instanceof errors.GoogleAdsFailure) {
console.log(err.errors); // Array of errors.GoogleAdsError instances
// Get the first one and explicitly check for a certain errors type
const [firstError] = err.errors;
if (
firstError.error_code ===
errors.QueryErrorEnum.QueryError.UNRECOGNIZED_FIELD
) {
console.log(
`Error: using invalid field "${firstError.trigger}" in query`
);
}
} else {
functions.logger.error(`type is ${typeof err}`);
}
console.error("ERROR");
}
return requestResponse;
}
The text was updated successfully, but these errors were encountered:
Hello, i have a very sstrange problem.
The library works very well on local, but when i use it in my cloud functions, i have an error that says the Promise took too much time. The promise await forever.
Thats my code
The text was updated successfully, but these errors were encountered: