Google Cloud Function 'node-pre-gyp/lib/pre-binding' - javascript

EDIT: I found the issue, when I copied the code I also duplicated the function. So I had cloud function "A" and "A Copy" and whenever I would pass information through the respective Pub/Sub, both functions are called and only one goes successfully through. I only did this because I thought having backup code somewhere would be safer and didn't expect it to make it not work.
So I've had a Google Cloud function running for the past 4 months.
Never any issues.
It uploads data I pass to it to FireStore.
I went to edit the code, but before I edited the code I made sure to backup the old code **index.js** and **package.json** just incase something broke.
Added a couple of new lines of code and of course the new code wasn't working so I reverted back to the old code.
However now the old code isn't working now and I'm getting:
Error: Cannot find module 'node-pre-gyp/lib/pre-binding'
so I commented everything and debugged as much as I could and found:
db.collection('LiveExamples5').add
({
Device: split[1],
Index: split[5],
Temperature: temp,
Humidity: split[9],
Raw: split[11],
Resistance: split[13],
VOC: split[15],
VDD: split[17],
Time: Timezz,
});
This is the piece of code that uploads the passed data to Firestore causes the error.
It's strange since this is the old code it's now causing this error and not uploading anything to FireStore now.
I'm not even sure how to install modules into Google Cloud functions.
Any help would be greatly appreciated.

Try adding the dependency of node-pre-gyp to the package.json file.

Related

Js function is not recognize in github page

I have uploaded my local project to github and turned it into github page.
All the functions are working properly in my localhost but, when I open the app via github page (this is repo for you to see code), it shows the error on console that the function calculateAmount() is not defined. See the screenshot
I have tried pushing the code to github again a few time to make sure it is not commit error. But, the error is still the same.
I have double checked the function name and it is the same.
I have no idea what is happening.
Please help.

webRTC video chat using Firestore

The code lab explaining webRTC and firestore is not clear enough to me.
https://webrtc.org/getting-started/firebase-rtc-codelab
I am having trouble with the final collectICECandidates step. Where should I be calling this function inside the code and how will I get the local and remote parameters required for the function?
I also needed help setting this up. The remotevideo was blank, and I got the 'Got room' in the console when I tried to connect.
To solve this, I found this on the Github's Solution branch:
https://github.com/webrtc/FirebaseRTC/blob/solution/public/app.js
You can find a corrected description in the following fork:
https://github.com/meldaravaniel/FirebaseRTC
And also there's a solution branch, were you can download the whole file from.

Using Ipinfo.io in Javascript

Okay, so, I'm trying to pull the correct region and city from Ipo.io but it isn't working. When ran locally it's giving me one location, which is wrong, and when deployed it also gives me a location but it's also wrong.
What I'm Trying To Do: pull the correct locations when user clicks a button.
The html is fine, so no need to add it. The js file where the request is looks like so (didn't include the whole file, just the relevant parts).
showMe is a modal that pops up once a user is scrolling the screen. Everything works fine the location is just wrong. I looked at the docs and it doesn't say anything about Javascript, so I'm writing to you guys in hopes that this tool actually works with Javascript.
Any help would be appreciated, thanks!
$('#showMe').click(() => {
$('#time-text').empty();
$.get("https://ipinfo.io?token=insert-token", function (response) {
$('#time-text').append(response.region);
}, "jsonp")
});
also, just to be clear, i've also tried this - as given in their documentation, but it throws an error.
$.get("https://ipinfo.io", function (response) {
$('#time-text').append(response.region);
}, "jsonp")
The error I am receiving for the last implemention is:
jquery-3.4.1.min.js:2 GET https://ipinfo.io/?callback=jQuery34105473588412770183_1578083636662&_=1578083636663 net::ERR_ABORTED 429
For the first implementation, there is no error - just wrong location.
You're getting a 429 Error, which means you've hit the request limit for the Day / Month (Depends)
Here is the relevant part of the the Docs discussing the Rate Limits

Google Sheets API node.js quickstart won't work: The API returned an error: Error: unauthorized_client

I've been messing with the Google Sheets API for a project and everything has been going pretty well. I followed all the steps On this page and got the quickstart working great for a while... Until I ran into an issue where I was getting the error message API returned an error: Error: The request does not have valid authentication credentials.
To resolve this I tried a bunch of different things from changing the SCOPES variable to commenting and uncommenting out things.
Eventually I deleted the project and credentials on my google developers console account and tried to make a new one.
Whenever I start a new folder from scratch, make a quickstart.js file, install the node modules and run it, now I get The API returned an error: Error: unauthorized_client. I've made completely new client_secret.json files and made the quickstart.js from scratch directly using the quickstart walkthrough code and it won't work. What could be causing this?
Link to github (this is the code that WAS mostly working until I tried to delete rows from my google sheet after copying data to my sql database).
You may want to try what was done in this SO post wherein this hidden file has been deleted:
/Users/user/.credentials/gmail-nodejs-quickstart.json
In your case, you need to locate the path of sheets.googleapis.com-nodejs-quickstart.json then delete.
For this, you might need to also do a console.log to locate the correct path.

Parse request.object.get("KEY") always returns undefined

I have a strange problem over here. I have a project built with Parse.com as a backend (using cloudcode to verify some things when a connection to the database is made). Everything works just as it should do.
But here comes the problem. Another developer reported to me that there is something wrong because he is getting 'undefined' every time he tries to call request.object.get('KEY')in CloudCode. This developer uses the exact same codebase as I do.
So I decided to have a look at it. While with my Parse account, every application works fine (even newly created ones), with the Parse account of the other developer, not a single new application we created seems to work with the exact same code. And it is getting even stranger - creating a completely new Parse account and a new application produces the same errors while my personal account and applications continue to work fine.
So what is the problem? We are using CloudCode, and here is sample code (in javascript) of a beforeSave method:
Parse.Cloud.beforeSave('Activity', function(request, response) {
var currentUser = request.user;
var objectUser = request.object.get('fromUser');
if(!currentUser || !objectUser) {
response.error('An Activity should have a valid fromUser.');
} else {
response.success();
}
});
And every time request.object.get('KEY') returns undefined, for every key I previously defined in the iOS code before uploading the PFObject.
Note that with my personal account everything is fine...
I have already seen this thread, however deleting ACL's didn't do the trick. request.object.get() stays undefined while request.useris defined for every tested Parse account except mine.
EDIT 1
I also had a look at the activity object just before it is uploaded, and there all the fields are properly set.
EDIT 2
After removing the cloud code completely, the objects are correctly being uploaded to Parse, with all the fields being the way they were set via the iOS client. So it seems that something is wrong with Parse's cloud code, but as soon as an object passes through cloud code, it looses all its fields.
Finally I was able to solve this. This is definitely a bug in Parse's Javascript SDK. I changed the Javascript SDK version in the global.json back to version "1.4.2" instead of "latest", uploaded this to the cloudcode folder and everything went back to normal.
You can also test other versions, maybe v1.5.0 is working too, but as soon as I found out v1.4.2 worked fine, I didn't try out more recent versions.
EDIT
So, I discovered, that Parse must have changed something in their command line tool. It seems that the global.json file isn't there anymore if you create your CloudCode folder with the most recent version of their command line tool. However, you can manually create it and upload the complete folder to your Parse app.
This is how my CloudCode folder looks like, just for example:
CloudCode folder contains three subfolders
• cloud - containing cloud code files
• config - containing the global.json file
• public - containing the index.html file
The global.json file contains these lines of code:
{
"global": {
"parseVersion": "1.4.2"
},
"applications": {
"YOUR_PARSE_APPS_NAME": {
"applicationId": "YOUR_APP_ID",
"masterKey": "YOUR_APP_MASTER_KEY"
},
"_default": {
"link": "YOUR_PARSE_APPS_NAME"
}
}
}

Categories

Resources