Lodash GET expected a function - javascript

I have the following Lodash function
flow(find({ id: args.roleRateId }), get('chargeRate'))(
args.roleRates
)
however, it doesn't work for what i need, inside the get i need to add get('chargeRate', args.roleRate) so it can get the chargeRate form the args.roleRate, but when i add this I do get
Uncaught TypeError: Expected a function
Anyone has any ideea why is that and how to fix it?

First you import import get from 'lodash/get'.
Then args.roleRate.chargeState would be got like get(args.roleRate, 'chargeState') or get(args, 'roleRate.chargeState').

Related

Why Frida (Inject) doesn't hook getPackageInfo and other methods?

I am having problems creating a script in JavaScript for Frida.
I want to hook the getPackageInfo method in order to log when it is called in the console, i have overloaded the old and the new version of it using this code:
jPM = Java.use('android.content.pm.PackageManager');
jPM.getPackageInfo.overload('java.lang.String','int').implementation=(pname,f)=>{
console.warn("Called => getPackageInfo ("+f+")");
return jPM.getPackageInfo.call(this,pname,f);
}
jPM.getPackageInfo.overload('android.content.pm.VersionedPackage','int').implementation=(vp,f)=>{
console.warn("Called => getPackageInfo [API level 33] ("+f+")");
return jPM.getPackageInfo.call(this,vp,f);
}
When i try to run the script I don't get any error, but I don't get any log in the console.
I am sure that the method that is being called is the first, because it's signature is this in smali:
Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;
I can't understand what am I doing wrong, if i use the same code to hook other methods it works. Please help me
I have solved this by using android.app.ApplicationPackageManager instead of android.content.pm.PackageManager.
Thanks to #Robert for giving me the link to this example code: https://codeshare.frida.re/#limyout/test/

I got a TypeError after i tried to implement "Edit" and "Delete" in a JavaScript form

I need to make a JavaScript form that allows you to edit or delete stuff that you submitted.
I used this tutorial (https://www.youtube.com/watch?v=-rNQeJi3Wp4), but when I tried to implement the edit function, it doesn't create the hyperlink, and when I click on it, it says
script.js:14 Uncaught TypeError: Cannot read property '0' of undefined.
at editRow (script.js:14)
at HTMLAnchorElement.onclick (index.html:1)"
Also I found out that the "selectedRow.cells" returns "undefined".
here is the code:
https://pastebin.com/pZVQ91D0
here is the function:
function editRow(td) {
//document.getElementById("AS").deleteRow(td);
selectedRow = td.parentElement.parentElement;
console.log(selectedRow.cells);
input.value = selectedRow.cells[0].innerHTML;
}
(The guy in the video solved the whole thing differently. I just tried to implement SOME of his code into my approach.)
Can you help me?
The value of selectedRow.cells is undefined so you are getting that error. The cells should have an some value. If you can add more code it will be helpful.

How can I get a json content from another js file?

I have two files:
// roles.js
export function roles() {
return {"/": ["admin","user"]};
}
// router.config.js
import {roles} from '../src/pages/.umi/roles'
console.log(roles['/']);
It throws:
TypeError: Cannot read property '/' of undefined
See? It is undefined. how can I make it accessible?
One of your mistakes is you're importing a function.
You should use roles()['/'] to get value
The other problem about undefined, probably is that you're importing wrong path like they're commenting.
Here you have an example that it runs.
https://stackblitz.com/edit/js-5cquau

React Flux Uncaught TypeError: _LocalityStore2.default.setSelectedLocality is not a function

I have HomeLayout from where I get redirected to MobileLocalityLayout which has a method selectLocality to set locality value to LocalityStore on clicking a link called "set locality". Now as soon as I select locality I am redirected to the HomeLayout and after that if press locality button again and select locality, I get following error:
Uncaught TypeError: _LocalityStore2.default.setSelectedLocality is not a function
However LocalityStore has the function setSelectedLocality.
Code Snippets:
HomeLayout :
<span class='selectLocalityBtn'><Link to="/selectLocality">Set Locality</Link></span>
MobileLocalityLayout:
selectLocality(val){
this.setState({
selectedLocality : val
});
LocalityStore.setSelectedLocality(val);
browserHistory.push("/");
}
LocalityStore:
setSelectedLocality(locality){
this.setSelectedLocality = locality;
}
Am I implementing flux in wrong way. I don't understand what is _LocalityStore2 as I have LocalityStore and not LocalityStore2. Please help.
You have a typo in your code
setSelectedLocality(locality){
this.setSelectedLocality = locality;
}
please replace this.setSelectedLocality with this.selectedLocality
It looks (by the name convention) like you are calling setSelectedLocality on a class and not instance. While exporting LocalityStore create an instance of it and then call methods on it. Like this:
const localityStore = new LocalityStore();
dispatcher.register(localityStore.handler.bind(localityStore));
export default localityStore;
About this name change (LocalityStore to _LocalityStore2). I guess you are using babel-react-loader or something like this to transpile your code to ES5. This causes some changes to the original code, but it's not a problem.

Titanium : uncaught type error

var menu = Titanium.UI.Android.OptionMenu.createMenu();
what it come up with when on the emulator it says
Message: uncaught TypeError: Cannot call method 'createMenu' of undefined
source: var menu = Titanium.UI.Android.OptionMenu.CreateMenu();
if you know what this all means would you be able to explain and help fix the problem.
Titanium.UI.Android doesn't have OptionMenu object.
Check documentation and describe what you are trying to do with more details.
The problem is Ti.UI.Android module doesn't have an OptionMenu object. If you want to create a menu, you can use Titanium.Android.Menu module.

Categories

Resources