https://love-calculator.p.rapidapi.com/getPercentage?fname=**${fname}**&sname=**${sname}**
Why does not show template literals under API? It's working as a string why? react-native can anyone explain why it's not showing as a template literals?
sorry, my English is very week.
import React, { useState } from 'react';
import { View, StyleSheet, Text, TextInput, Button } from 'react-native';
import DisplayPer from './DisplayPer';
const Body = () => {
const [fname, setfname] = useState("")
const [sname, setsname] = useState("")
const calculate = () => {
fetch("https://love-calculator.p.rapidapi.com/getPercentage?fname=${fname}&sname=${sname}", {
"method": "GET",
"headers": {
"x-rapidapi-key": "00298dcae5mshba42f70f49fc1b6p148d95jsn941e18e734e5",
"x-rapidapi-host": "love-calculator.p.rapidapi.com"
}
})
.then(response => response.json())
.then(result => {
console.log(result)
})
}
return(
<View style={styles.bodycontainer}>
<Text style={styles.bodytext}>Enter Friends Data</Text>
<TextInput
style={styles.bodyinput}
placeholder="Type here!"
onChangeText={(event)=> setfname(event)}
/>
<TextInput
style={styles.bodyinput}
placeholder="Type here!"
onChangeText={(event)=> setsname(event)}
/>
<Button
onPress={calculate}
title="Learn More"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
<DisplayPer />
</View>
)
}
export default Body;