I have an App where I set login and password using __DEV__ in order to do some quick tests.
Like:
const [email, setEmail] = useState(__DEV__ ? 'my.email#gmail.com' : '')
const [password, setPassword] = useState(__DEV__ ? 'mypassword' : '')
Is it possible for some hacker to extract data from the bundle from the App Store or the Play Store? I guess not, but how to be 100% sure?
Related
Well I'm new to this app development thing especially react-native and I wanted to know when I'm trying to scrap a website using cheerio and axios in react-native and then save it to firebase realtime database in the following way:
and yes i have done all the imports and also initalized my app using firebaseConfig
const db = firebase.database();
async function loadFurniture() {
const Url = 'https://hoid.pk/product-category/bedroom/beds-bedroom/';
const html = await axios.get(Url); // fetch page
const $ = cheerio.load(html); //parse html String
const furniture = [];
$('.product-wrapper ').each((i, element) => {
const title = $(element).find('h2.product-name').text();
const imageUrl = $(element).find('img.primary_image').attr('src');
const price = $(element).find('span.woocommerce-Price-amount amount').text();
console.log(title);
furniture.push({ title, imageUrl, price });
});
// Save the furniture to the Firebase Realtime Database
db
.ref('/furniture/bed')
.set({
title: furniture.title,
price: furniture.price,
object_image : furniture.imageUrl,
})
.then(() => console.log('Data set.'));
console.log(furniture);
// Return the extracted information
return furniture;
}
and then calling this function in a button
<Button
title="Fetch"
onPress = {() => loadFurniture() }
/>
The data was not being scraped so I tried to console.log() the data being fetched.
Whenever I click the button there is no error but just a log [ Function initialize ] with respect to console.log(title)
And before anyone says yup I've looked into the structure and 9it does returns me my desired classes after axios.get()
I just want to know that if there's some error in my code or if I'm going wrong somewhere.
I tried to scrap furniture titles, images and prices from certain website and then save it to database for any further use but it's just not working.
I've checked my network issues the html page being scraped and everything else one can think of. Now i just want to know either my code is accurate or if there's some mistake.
I tired to scrap the data of same website using python and it scraps it perfectly.
Edit:
I found out that the cheerio.load() function is not working there was no problem with the database... Is there some problem with cheerio.load() in it's latest version "1.0.0-rc.12" ?? If so what's the solution... I've tried number of libraries and each is giving a different kind of error so cheerio might be the only possible solution so if there's an alternative way of using cheerio.load() in react native do let me know.
I implemented Google analytics in the React native app.
The code to log the screen is as follows.
<NavigationContainer
linking={linking}
ref={(navigationRef) =>
(this.navigationRef = navigationRef)
}
onReady={() => {
this.routeNameRef =
this.navigationRef.getCurrentRoute().name;
// first log in init
Analytics.logScreenView({
screen_name: this.routeNameRef,
screen_class: this.routeNameRef,
});
}}
onStateChange={async () => {
const previousRouteName = this.routeNameRef;
const currentRoute = this.navigationRef.getCurrentRoute();
const currentRouteName = currentRoute.name;
const currentScreenName =
(currentRoute.params &&
currentRoute.params.screenName) ||
currentRouteName;
if (previousRouteName !== currentRouteName) {
await Analytics.logScreenView({
screen_name: currentScreenName,
screen_class: currentRouteName,
});
}
// Save the current route name for later comparision
this.routeNameRef = currentRouteName;
}}
>
After the app was released, I tried to determine which page the user was browsing in Google Analytics path exploration.
But when i set STARTING POINT to "first_open"(the first time a user launches an app after installing or re-installing it), STEP 1's page title and screen name is set to (not set)
What is wrong with this? What am i doing wrong?
and step2 has 39 event count, but step3 has 35 event count.
where is 4 event count? 4 user exited app?
Is there something wrong with the way I look at the report?
How exactly is it to access the app and see which page the user has moved to?
Debugging did not detect that screen name was not set.
How to use "remove()" in SDK v9 web?
(context: I'm learning React Native (using Expo) and there's this todo app).
There are no examples in the documentation. Here is what I have:
// firebase
import app from "./firebaseConfig";
import {
getDatabase,
ref,
set,
push,
onValue,
remove,
child,
} from "firebase/database";
// etc
const db = getDatabase(app);
const taskListRef = ref(db, "tarefas/" + user);
const newTaskRef = push(taskListRef);
// etc
const handleDelete = (key) => {
remove(taskListRef).then(() => {
const findTasks = tasks.filter((item) => item.key !== key);
setTasks(findTasks);
});
};
So, this remove(taskListRef) is my problem. I don't know how to call it properly regarding the reference to the data location.
I've tried: remove(taskListRef.child(user)), remove(taskListRef.child(key)) etc... and a bunch of other similar things. The error always: wrong reference.
Here is the repo. Please, help. Thank you all in advance.
P.S.: hopefully I won't have to ask a similar question regarding update().
I'm working on an electron app and im using cryptocompare api to display BTC price but it dosen't displays. I've tried every solution i could think of, some help would be appreciated!!
const electron = require('electron');
const path = require('path');
const BrowserWindow = electron.remote.BrowserWindow;
const axios = require('axios');
const notifyBtn = document.querySelector('.notify-btn');
const price = document.querySelector('.price');
const targetPrice = document.querySelector('.target-price');
function getBTC(){
const cryptos = axios.get('https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD&api_key={api_key}')
price.innerHTML = '$'+cryptos
}
getBTC();
setInterval(getBTC, 20000);
It gives me an output of '$[object Promise]'
In the documentation for axios, it says you need to do this instead:
axios.get(url)
.then(function (response) {
// do something with response
});
This is because the value returned by axios.get isn't a response, it's a promise that will resolve to a response. (So it gets coerced to the string [object Promise].) If you don't know what this means, read this link. Basically promises are a way of dealing with tasks that take a long time to run (such as api calls) without blocking other javascript code from runnning. But anyway, what you want is this:
function getBTC(){
axios.get('https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD&api_key={api_key}')
.then(function(response) {
var data = response.data;
var cryptos = // get cryptos from data somehow
price.innerHTML = '$'+cryptos;
});
}
I haven't read the axios documentation in detail. I believe what you are looking for is in response.data, but I couldn't tell you any more than that. Try console.log('Response:', response); to find out how the response is structured.
I'm looking to make a fetch request to an API, in my code I added a text input:
constructor(props) {
super(props)
this.state = {
UserInput: '',
}
}
<TextInput onChangeText={(UserInput) =>
this.setState({UserInput})} value={this.state.UserInput} />
I can definitely see UserInput variable if I render <Text>{this.state.UserInput}</Text> in my view, however I'm trying to use that variable to generate a dynamic url path for my api request.
The url looks like that https://api.trading.com/1.0/stock/msft/company msft is what I have to change by UserInput
In pure javascript, I usually do something like this:
const userstock = UserInput;
const path = "https://api.trading.com/1.0/stock/";
const end = "/company";
const url = path + userstock + end;
I changed var by const because it's react native but it's still not working,
Can't find variable: UserInput
I also tried https://api.trading.com/1.0/stock/${UserInput}/company can someone help on this please? Thanks
As you write,it works if you render <Text>{this.state.UserInput}</Text>!
Why not write like this:
const userstock = this.state.UserInput;
or :
"https://api.trading.com/1.0/stock/"+ this.state.UserInput +"/company"
I suggest you should read official document and learn more about props and state!