how can I reference the text of a button I click?

So I am making a app that shows a list of result. what I want is that when I click on that result it search that. so I made the text box buttons where my results will appear but I can’t access the text of the button I clicked.

string url;
public InputField input;
public TextMeshProUGUI text;
public Button[] output;

string fixJson(string value)
    value = "{\"Items\":" + value + "}";
    return value;
public void GetData() => StartCoroutine(GetData_Coroutine());
public IEnumerator GetData_Coroutine()
    url = "" + input.text;
    using (UnityWebRequest request = UnityWebRequest.Get(url))
        yield return request.SendWebRequest();
        if (request.result == UnityWebRequest.Result.ConnectionError)
            output[1].text = request.error;
            string jsonString = fixJson(request.downloadHandler.text);
            Rhyme[] rhyme = JsonHelper.FromJson<Rhyme>(jsonString);
            output[0].text = rhyme[0].word;
            output[1].text = rhyme[1].word;
            output[2].text = rhyme[2].word;
            output[3].text = rhyme[3].word;
            output[4].text = rhyme[4].word;


Two things. The following code will address the TextMeshPro component that is a child of the Button and read the text.

using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class ReadButton : MonoBehaviour
    public void OnButtonPressed()

You also need to set up the addressability. In the Inspector, point at the GameObject that contains the script (in this case I’ve put the script on the Button itself) . Then select the public method that will extract your text.