Google image scraper in Apify using the extended output function - web-scraping

In Apify -
Google Shopping Scraper - emastra/google-shopping-scraper
does not scrape images.
Over here - https://github.com/apify-projects/store-google-search-scraper/issues/84
Tells me how.
But it didn't work, because I don't understand it.
Here are my results when I plug it into the Extended output function:
A simple log showing an error.
So I tried fixing it by forcing results. Here was my theory that ended up failing:
async ({ label, Apify, $, request }) => {
if (label === 'HANDLE' && request.url.includes('tbm=isch')) { // image tab
// dataset will be full of { data: 'base64', link: 'https://...' }
const result = await Apify.pushData(
$('[jsname="r5xl4"] > [jsaction]').map((_, el) => {
const $el = $(el)
return {
data: $el.find('img[src^="data"]').attr('src'),
link: $el.find('>a[href]').attr('href'),
}
}).get()
)
}
return result
}
And the results are as follows:
2022-11-17T04:08:07.813Z ACTOR: Pulling Docker image from repository.
2022-11-17T04:08:19.700Z ACTOR: Creating Docker container.
2022-11-17T04:08:21.974Z ACTOR: Starting Docker container.
2022-11-17T04:08:23.198Z Starting X virtual framebuffer using: Xvfb :99 -ac -screen 0 1280x720x16 -nolisten tcp
2022-11-17T04:08:23.200Z Executing main command
2022-11-17T04:08:25.043Z INFO System info {"apifyVersion":"2.3.2","apifyClientVersion":"2.6.0","osType":"Linux","nodeVersion":"v16.17.0"}
2022-11-17T04:08:25.411Z INFO Search URLs:
2022-11-17T04:08:25.412Z http://www.google.com/search?q=iPhone&tbm=shop&tbs=vw:l
2022-11-17T04:08:25.581Z INFO Starting crawler.
2022-11-17T04:08:25.640Z INFO PuppeteerCrawler:AutoscaledPool: state {"currentConcurrency":0,"desiredConcurrency":2,"systemStatus":{"isSystemIdle":true,"memInfo":{"isOverloaded":false,"limitRatio":0.2,"actualRatio":null},"eventLoopInfo":{"isOverloaded":false,"limitRatio":0.6,"actualRatio":null},"cpuInfo":{"isOverloaded":false,"limitRatio":0.4,"actualRatio":null},"clientInfo":{"isOverloaded":false,"limitRatio":0.3,"actualRatio":null}}}
2022-11-17T04:08:37.551Z INFO Processing: http://www.google.com/search?q=iPhone&tbm=shop&tbs=vw:l
2022-11-17T04:08:37.552Z INFO Number of page: 1
2022-11-17T04:08:37.605Z INFO Found 12 products on the page.
2022-11-17T04:08:37.669Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:37.746Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:37.816Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:37.852Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:37.895Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:37.939Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:37.980Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.036Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.083Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.135Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.197Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.243Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.276Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.324Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.355Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.397Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.442Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.482Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.521Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.564Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.601Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.694Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.728Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.762Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.802Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.861Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.907Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.947Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:38.981Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.015Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.071Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.142Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.182Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.224Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.266Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.301Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.333Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.371Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.425Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.460Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.493Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.837Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.878Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:39.932Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.009Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.054Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.186Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.223Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.296Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.364Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.405Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.454Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.507Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.612Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.651Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.693Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.738Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.773Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.804Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.852Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.891Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.943Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:40.980Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:41.015Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:41.050Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:41.110Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:41.140Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:41.176Z INFO extendOutputFunctionfailed. Returning default output. Error: ReferenceError: result is not defined
2022-11-17T04:08:41.228Z INFO 0 items on the page were successfully scraped.
2022-11-17T04:08:41.349Z INFO PuppeteerCrawler: All the requests from request list and/or request queue have been processed, the crawler will shut down.
2022-11-17T04:08:41.577Z INFO PuppeteerCrawler: Final request statistics: {"requestsFinished":1,"requestsFailed":0,"retryHistogram":[1],"requestAvgFailedDurationMillis":null,"requestAvgFinishedDurationMillis":14044,"requestsFinishedPerMinute":4,"requestsFailedPerMinute":0,"requestTotalDurationMillis":14044,"requestsTotal":1,"crawlerRuntimeMillis":15998}
2022-11-17T04:08:41.579Z INFO Crawler Finished.
So. I am out of ideas. Anybody know what to do?
So I think I made some progress...
I put in this:
async ($) => {
result = {
data: "test",
link:"test",
};
if (true) { // image tab
// dataset will be full of { data: 'base64', link: 'https://...' }
result =
$('[jsname="r5xl4"] > [jsaction]').map((_, el) => {
const $el = $(el)
return {
data: $el.find('img[src^="data"]').attr('src'),
link: $el.find('>a[href]').attr('href'),
}
}).get()
}
return result
}
and got:
2022-12-02T17:37:24.077Z ACTOR: Pulling Docker image from repository.
2022-12-02T17:37:34.147Z ACTOR: Creating Docker container.
2022-12-02T17:37:34.672Z ACTOR: Starting Docker container.
2022-12-02T17:37:35.658Z Starting X virtual framebuffer using: Xvfb :99 -ac -screen 0 1280x720x16 -nolisten tcp
2022-12-02T17:37:35.659Z Executing main command
2022-12-02T17:37:36.715Z INFO System info {"apifyVersion":"2.3.2","apifyClientVersion":"2.6.0","osType":"Linux","nodeVersion":"v16.17.0"}
2022-12-02T17:37:37.011Z INFO Search URLs:
2022-12-02T17:37:37.012Z http://www.google.com/search?q=iPhone&tbm=shop&tbs=vw:l
2022-12-02T17:37:37.178Z INFO Starting crawler.
2022-12-02T17:37:37.230Z INFO PuppeteerCrawler:AutoscaledPool: state {"currentConcurrency":0,"desiredConcurrency":2,"systemStatus":{"isSystemIdle":true,"memInfo":{"isOverloaded":false,"limitRatio":0.2,"actualRatio":null},"eventLoopInfo":{"isOverloaded":false,"limitRatio":0.6,"actualRatio":null},"cpuInfo":{"isOverloaded":false,"limitRatio":0.4,"actualRatio":null},"clientInfo":{"isOverloaded":false,"limitRatio":0.3,"actualRatio":null}}}
2022-12-02T17:37:48.057Z INFO Processing: http://www.google.com/search?q=iPhone&tbm=shop&tbs=vw:l
2022-12-02T17:37:48.058Z INFO Number of page: 1
2022-12-02T17:37:48.068Z INFO Found 63 products on the page.
2022-12-02T17:37:48.158Z ERROR
2022-12-02T17:37:48.159Z Error: extendOutputFunction must return an object!
2022-12-02T17:37:48.159Z at applyFunction (/home/myuser/src/utils.js:45:23)
2022-12-02T17:37:48.160Z at processTicksAndRejections (node:internal/process/task_queues:96:5)
2022-12-02T17:37:48.160Z at async Object.exports.SEARCH_PAGE (/home/myuser/src/routes.js:102:20)
2022-12-02T17:37:48.161Z at async wrap (/home/myuser/node_modules/apify/node_modules/#apify/timeout/index.js:73:27)

In the first piece of code, the error log is saying where is the issue: result is not defined - that is because you are defining the result variable in the if (...) {...} block, and after that block ends, the variable goes out of scope, so you can't access (and therefore return) it. A solution for that would be to define it before the block, and only assign a value inside, so something like this:
async (args) => {
let result = "";
if (condition) {
result = // ... more code
}
return result
}
I'm not sure what exactly you're trying to achieve, but Apify generally uses the convention that user-supplied extendOutput functions should return an object that is then merged with the data scraped by the scraper itself, and you shouldn't directly call Apify.pushData (I'm not sure what the linked GitHub issue where you found this code wants to say). So for example, if a scraper scrapes {productName: "iPhone 11", url: "https://example.com"} and your extendOutputFunction returns {imageData: "base64", imageLink: "https://example.com/image.jpg"}, the final output will contain all these four properties, i.e. {productName: "iPhone 11", url: "...", imageData: "...", imageLink: "..."}.
The log for the second piece of code that you tried also says what you're doing wrong: extendOutputFunction must return an object, but $(...).map(...).get() returns an array (see cheerio docs). If you want just the first item, use .get(0)

Related

ReferenceError: document is not defined This error happened while generating the page. Any console logs will be displayed in the terminal window

requestAnimationFrame(this.animate), this.conf.playing = true
}), e(this,"initGradient", (selector) => {
> this.el = document.querySelector(selector);
^
this.connect();
return this;
})
ReferenceError: document is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
enter image description here

Meteor Amazon s3 delete image

I have successfully uploaded an image to amazon s3 with this meteor package
https://github.com/Lepozepo/S3 Now I am trying to delete the file, which I am getting a error on.
This is the documentation for the s3.delete code
S3.delete(path,callback)
This function permanently destroys a file located in your S3 bucket.
Parameters:
path: Must be in this format ("/folder/other_folder/file.extension").
So basically always start with "/" and never end with "/". This is
required.
callback: A function that is run after the delete operation
is complete returning an Error as the first parameter (if there is
one), and a Result as the second.
This is my upload and delete code
Template.postSubmit.events({
"click button.upload": function(){
var files = $("input.file_bag")[0].files
S3.upload({
files:files,
path:"uploads"
},function(e,r){
console.log(r);
delete_url = r.relative_url;
console.log(delete_url);
});
},
"click button.delete": function(){
S3.delete({
path:delete_url
},function(e,r){
console.log(e);
console.log(r);
});
}
});
The error I get when hitting the delete button.
errorClass {isClientSafe: true, error: 400, reason: "Match failed", details: undefined, message: "Match failed [400]", …}
details
:
undefined
error
:
400
errorType
:
"Meteor.Error"
isClientSafe
:
true
message
:
"Match failed [400]"
reason
:
"Match failed"
stack
:
"Error↵ at Connection._livedata_result (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:4823:23)↵ at onMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:3528:206)↵ at http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:2908:9↵ at Array.forEach (<anonymous>)↵ at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:149:11)↵ at SockJS.self.socket.onmessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:2907:43)↵ at SockJS.REventTarget.dispatchEvent (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:142:28)↵ at SockJS._dispatchMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1309:14)↵ at SockJS._didMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1375:26)↵ at WebSocket.that.ws.onmessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1531:21)"
__proto__
:
Error
Update
This is the error I got on the server in terminal side
Exception while invoking method '_s3_delete' Error: Match error: Expected string, got object
You should call it like this:
S3.delete(delete_url, function() { ... });
First parameter should be url itself, not the object like in your example.

where to write the AutoForm.addHooks() code to manipulate the submitted autoform values

Below is the hook code that I want to use to manipulate the submitted values from QuickForm.
var hooksObject = {
before: {
insert: function(doc) {
console.log(doc);
return doc;
}
}
};
AutoForm.addHooks('insertBankDetailForm', hooksObject, true);
I have read the docs and it says "These calls should be anywhere in top-level client code and do not need to be within Meteor.startup. You should not put them in an autorun, template rendered function, or anywhere else where they will be called multiple times since that will cause the hooks to run multiple times for a single submission."
I tried placing the code most of the places, but I am unable to understand the location where it need to be kept. I get below error when I use above code in index.js at location D:\PROJECT\imports\startup\client\index.js
Error: Oops! Did you forget to return the modified document from your docToForm hook for the insertBankDetailForm form?
at autoFormEachDocToForm (aldeed_autoform.js?hash=62240ad…:6595)
at Array.forEach (<anonymous>)
at Function._.each._.forEach (underscore.js?hash=cde485f…:149)
at Blaze.View.<anonymous> (aldeed_autoform.js?hash=62240ad…:6592)
at blaze.js?hash=f33d3df…:1934
at Function.Template._withTemplateInstanceFunc (blaze.js?hash=f33d3df…:3744)
at blaze.js?hash=f33d3df…:1932
at Object.Blaze._withCurrentView (blaze.js?hash=f33d3df…:2271)
at viewAutorun (blaze.js?hash=f33d3df…:1931)
at Tracker.Computation._compute (tracker.js?hash=997515f…:339)
meteor.js?hash=27829e9…:930 Exception from Tracker recompute function:
meteor.js?hash=27829e9…:930 TypeError: Cannot read property 'setMembers' of undefined
at doMaterialize (blaze.js?hash=f33d3df…:2093)
at Object.Tracker.nonreactive (tracker.js?hash=997515f…:640)
at Blaze.View.doRender (blaze.js?hash=f33d3df…:2090)
at blaze.js?hash=f33d3df…:1934
at Function.Template._withTemplateInstanceFunc (blaze.js?hash=f33d3df…:3744)
at blaze.js?hash=f33d3df…:1932
at Object.Blaze._withCurrentView (blaze.js?hash=f33d3df…:2271)
at viewAutorun (blaze.js?hash=f33d3df…:1931)
at Tracker.Computation._compute (tracker.js?hash=997515f…:339)
at Tracker.Computation._recompute (tracker.js?hash=997515f…:358)
aldeed_autoform.js?hash=62240ad…:2037 Uncaught TypeError: Cannot read property 'removeEmptyStrings' of undefined
at Object.autoFormGetFormValues [as getFormValues] (aldeed_autoform.js?hash=62240ad…:2037)
at autoFormRegFormCallback (aldeed_autoform.js?hash=62240ad…:6575)
at aldeed_autoform.js?hash=62240ad…:670
at Function._.each._.forEach (underscore.js?hash=cde485f…:157)
at formPreserveConstructor.FormPreserve._retrieveRegisteredDocuments (aldeed_autoform.js?hash=62240ad…:669)
at Object.callback (aldeed_autoform.js?hash=62240ad…:628)
at pollProviders (reload.js?hash=02487cd…:180)
at Object.Reload._migrate (reload.js?hash=02487cd…:198)
at reload.js?hash=02487cd…:252
at underscore.js?hash=cde485f…:717
NOTE: Any help would be deeply appreciated and rewarded.

Error when trying to deploy ethereum contract, probably due to meteor's modules/scripts

I have my meteor project
which when i run i get the following warnings:
First warning:
Mismatched anonymous define() module: function () { return BigNumber; }
intakeDefines # aramk_requirejs.js?hash=a2cd915…:1278
(anonymous) # aramk_requirejs.js?hash=a2cd915…:1469
Second warning:{...}
Mismatched anonymous define() module: function () { return utf8; }
and when i run my project i get the following error
Uncaught TypeError: Right-hand side of 'instanceof' is not callable
at isBigNumber (http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:5598:19)
at toBigNumber (http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:5465:9)
at Object.fromDecimal (http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:5343:18)
at http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:2613:30
at Array.forEach (native)
at inputTransactionFormatter (http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:2612:8)
at http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:2910:28
at Array.map (native)
at Method.formatInput (http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:2909:32)
at Method.toPayload (http://localhost:3000/packages/modules.js?hash=6e90e44e0c2b18ef12cb22415a388acb1e06ad7f:2935:23)
The line of code where the problem occurs is this: web3.eth.contract(abi).new({data: code,gas:10000}, function (err, contract) {..irrelevant code..} After searching on the internet I think that it is require.js's fault and how the scripts are called but still don't know how to fix it. I already looked over the documentation but still need some help.

Meteor Iron:Route with Meteor 1.2

I'm learning Meteor by following this tutorial.
Here is my git https://github.com/nicholaschong12/meteor-slackclone
I'm getting this error:
Uncaught TypeError: Cannot read property 'channel' of undefined
Uncaught TypeError: Function.prototype.apply: Arguments list has wrong
type
Meteor.startup(function(){
Session.set('channel',this.params.channel);
});
Please help me to understand this error.
Thank You
Looking at the error:
Uncaught TypeError: Cannot read property 'channel' of undefined
We can see that it is trying to read a property 'channel' of an undefined object. This object from your code is:
this.params
Reading the iron:router docs, tells us that:
When a user goes to that url, the actual value of the parameter will be stored as a property on this.params in your route function.
However in the code snippet you provided:
Meteor.startup(function(){
Session.set('channel',this.params.channel);
});
You are trying to access this.params inside a Meteor.startup callback function, not a Router.route function. In this context this.params is undefined, as the error is telling you.
Change your startup code to match the tutorial:
Meteor.startup(function() {
Session.set('channel', 'general');
});
And in your routing code you can use values from the route like this:
Router.route('/:channel', function () {
Session.set('channel', this.params.channel);
this.render('messages');
});
In this context this.params will return an object, including the channel property defined in the routes path.

Resources