I am learning to work with Bash and APIs, and am currently stuck on a problem related to nested variables.
The basic action I wish to do looks like this:
name="peter"; country="uk";
gender=$(http -b GET "https://api.genderize.io/?$name=peter&country_id=$uk" | jq -e '.gender');
echo $gender
output is
"male"
The complete action I want to take looks like this:
while read name <&3 && read country <&4
do gender=$(http -b GET "https://api.genderize.io/?name=$name&country_id=$country" | jq -e '.gender')
echo "$name : $gender" >> namesorted.txt
sleep 0.1
done 3<namelist.txt 4<countrylist.txt
but the output is null, which means that the request wasn't sent correctly:
Peter : null
Edouard : null
Henri : null
Anabelle : null
Nonso : null
Tom : null
What's wrong with my code? And is there a way for me to see the query sent by the code for debugging purposes?
edit: it ended up being a formatting mistake, as pointed out in the comments. Thanks!