I have an API that is going to be spitting out a few dozen objects, each one containing a promo_url
and a promo_number
, in order to do dynamic number swapping on my Gatsby site. Like so:
[{
"promo_url": "/promo1",
"promo_number": "665-894-3142"
},
{
"promo_url": "/promo2",
"promo_number": "493-441-7386"
},
{
"promo_url": "/promo3",
"promo_number": "549-823-5785"
},
{
"promo_url": "/promo4",
"promo_number": "553-747-1261"
},
{
"promo_url": "/promo5",
"promo_number": "253-741-2776"
}]
Essentially, what I need to do is find and set the user's referral
URL, check through the data, find the URL that matches it, and then pass the related phone number to my components through a context, however I have no idea how to check the objects, find the matching URL, and then pass the related phone number. Does anyone have any ideas on how/where I should begin?