# Response time API call too large

**URL:** <https://community.homey.app/t/response-time-api-call-too-large/84633>\
**Category:** Developers\
**Created:** [July 15, 2023, 11:42am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633 "2023-07-15T11:42:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThaYoung1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thayoung1/32/70101_2.png) [@ThaYoung1](https://community.homey.app/u/ThaYoung1)\
**Post date:** [July 15, 2023, 11:42am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/1 "2023-07-15T11:42:38Z")

</div>

Hi,

I have developed the Strava app for Homey ([Strava App voor Homey | Homey](https://homey.app/nl-nl/app/com.thayoung1.strava/Strava/)).

Codebase is on Github ([GitHub - ThaYoung1/com.thayoung1.strava](https://github.com/ThaYoung1/com.thayoung1.strava)).

As soon as an item on Strava is created/edited, my App receives an API call (not being an official Homey webhook call) which is handled by the code in my api.js file. So far so good.

Problem is that the POST API method of my App returns a very slow response. Often the response takes about 6 seconds or more. Strava sees that as a failure and will try again and again up untill 3 times. My App does not have to check things before returning a HTTP 200 OK, it could be sent immediately after receiving the call.

I have been experiencing with async handling but can’t get the API method just to accept the call and directly return a HTTP 200 OK.

Can anybody help me to get this thing resolved?

Regards,

ThaYoung1

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 15, 2023, 1:16pm UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/2 "2023-07-15T13:16:16Z")

</div>

> [@ThaYoung1](#):
>
> Can anybody help me to get this thing resolved?

So what exactly is taking up those 6 seconds?

---

<div class="post-metadata">

**Author:** ![ThaYoung1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thayoung1/32/70101_2.png) [@ThaYoung1](https://community.homey.app/u/ThaYoung1)\
**Post date:** [July 18, 2023, 7:42am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/3 "2023-07-18T07:42:23Z")

</div>

Hey @robertklep,

Thanks for your reply.

The App does all kinds of things after receiving a request from Strava;

- it GETs the full Activity details by requesting the Strava API
- it processes the activity details, calculates new metrics and starts the relevant Homey flow action cards

The thing is, I don’t want the API on my Homey App side, which is called by Strava to be waiting on all these actions; after receiving the request I want it to directly respond with an OK so it won’t be seen as a timeout from Strava’s perspective. I thought that a async method would fix that, but it looks like it is still waiting.

I am thinking about trying to introduce a queueing mechanism in which I just receive the API call from Strava, save it in the queue and subsequently process it in parallel with another process. That will fix it, but I was wondering if there was a ‘quick fix’ so I don’t have to introduce queueing for it.

Regards

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 18, 2023, 7:55am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/4 "2023-07-18T07:55:28Z")

</div>

You now have this:

```auto
    async get({ homey, query }) {
      // you can access query parameters like "/?foo=bar" through `query.foo`
      const result = await homey.app.get(query);
      return result;
    },

```

This means that the API endpoint will wait for `homey.app.get()` to complete before it returns the result.

If you just want to send back a generic response, you can remove the `await`:

```auto
    async get({ homey, query }) {
      homey.app.get(query);
      return 'ok'; // or whatever response Strava wants
    },

```

This will “schedule” `homey.app.get()` to run, but it will not wait for its completion. So the response of the API endpoint should be fast enough for Strava not to think it’s a failure.

---

<div class="post-metadata">

**Author:** ![ThaYoung1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thayoung1/32/70101_2.png) [@ThaYoung1](https://community.homey.app/u/ThaYoung1)\
**Post date:** [July 21, 2023, 7:22am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/5 "2023-07-21T07:22:28Z")

</div>

Hi, my GET method needs to wait on response, which is no problem because the code behind it executes fast / does not rely on external systems.

The problem I am describing occurs with the POST method, which already does a function call without await. But that method still gives slow response / seems to be waiting for all further processing before giving an HTTP response to the external system.

```auto
  async post({ homey, body }) {
        // access the post body and perform some action on it.
        homey.app.post(body)
        
        return null;
    },

```

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 21, 2023, 8:20am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/6 "2023-07-21T08:20:39Z")

</div>

So when you remove the call to `homey.app.post(body)`, it works? Also, have you tried returning anything else besides `null`?

---

<div class="post-metadata">

**Author:** ![ThaYoung1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thayoung1/32/70101_2.png) [@ThaYoung1](https://community.homey.app/u/ThaYoung1)\
**Post date:** [July 21, 2023, 10:26am UTC](https://community.homey.app/t/response-time-api-call-too-large/84633/7 "2023-07-21T10:26:18Z")

</div>

I will give it a try and report back the results here.
