# Retweet Frontend

There are superficial UI differences when comparing the Retweet Task app to the more general Task app. But we're going to ignore most of them while only focusing on the key changes related to the retweet verification logic.

After the task taker clicks the "complete" button, this is where the new business logic kicks in. It will trigger a secure oracle API call in the backend and verify that this is a successful retweet.

Let's take a look at the front end code trigged by the "complete" button, which is located at `src/layer2/task.js` and specifically inside the `async completeTask` callback section:

```
cb: async (form, close) => {
        self.$root.loading(true);

        let tweet = form.text;
        if(reg_tweet.test(tweet)){
          const arr = tweet.match(reg_tweet);
          tweet = arr[2];
        }

        const opts = {
          address: self.layer1_account.address,
          tappIdB64: base.getTappId(),
          authB64: session_key,
          subject: param.subject,
          text: tweet
        };

        try {
          await txn.txn_request('complete_task', opts);
          await succ_cb();
        } catch (e) {
          console.error(e);
          self.$root.showError(e.toString());
          if(error_cb){
            await error_cb();
          }
        }
        close();
        self.$root.loading(false);

      }
```

This code first takes the tweet url then parses and puts it into the opts. After that it sends a txn request: `await txn.txn_request('complete_task', opts);`.

Right after the txn\_request, it starts to `await succ_cb()`. This makes the front end wait for the successful return from the backend, at which point the waiting ends.

This front end logic is fairly basic and is typical of what a front end is supposed to do. The majority of the main logic happens in the backend.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.teaproject.org/020_tutorial/065_retweet/066_retweet_front_end.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
