I am trying to change all of the '%2F'
and '%2B'
into '/'
and '+'
in order to retrieve an URL from Firebase
for an encoded image, but somehow it shows me an error of undefined
is not an object (evaluating 'NewText.replace'
)
Here's the part of the code:
getURL(){
db.ref('/').once('value', (data) =>{
let RetrieveData=data.toString();
var NewText = RetrieveData.photoPath;
var FinalText = NewText.replace(/%2F/g, "/").replace(/%2B/g, "+");
this.setState({
urlHolder: FinalText,
})
});
}
Is it because the .replace
function can't replace numbers? If so, what function should I use then?
question from:
https://stackoverflow.com/questions/65937640/replace-function-wont-replace-numbers-in-javascript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…