# Async function weird behavior

**URL:** <https://forum.wixstudio.com/t/async-function-weird-behavior/28315>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [April 6, 2020, 1:03am UTC](https://forum.wixstudio.com/t/async-function-weird-behavior/28315 "2020-04-06T01:03:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trustygenius](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/trustygenius/32/14304_2.png) [@trustygenius](https://forum.wixstudio.com/u/trustygenius)\
**Post date:** [April 6, 2020, 1:03am UTC](https://forum.wixstudio.com/t/async-function-weird-behavior/28315/1 "2020-04-06T01:03:42Z")

</div>

Hi All,

I am just trying to insert an entity into a table with async and await. Here is my code:

$w.onReady( **async function** () {  
local.setItem(“templateId”, “0c256053-506c-491f-9c5a-58254c82f1fb”);  
**const** action = **await** insertAction();  
});  
**async function** insertAction() {  
**const** today = **new** Date();  
**const** time = today.getTime();  
**let** action = {  
“accessTimestamp”: time,  
“templateId”: local.getItem(“templateId”),  
“ipAddress”: local.getItem(“ipAddress”)  
};  
**const** actions = **await** wixData.insert(“Actions”, action);  
local.setItem(“functionofuID”, actions.\_id);  
console.log("inside insert action: " + actions);  
console.log("action id is " + local.getItem(“functionofuID”));  
}

Every time I load this page, I am seeing two entities created with different ids. I don’t understand why its creating two entities when I am calling insertAction only once.

I don’t even see the logs twice. So I don’t know which part is creating second entity.

Any help on this please.

Thank you,  
Divya.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [April 6, 2020, 4:58am UTC](https://forum.wixstudio.com/t/async-function-weird-behavior/28315/2 "2020-04-06T04:58:30Z")

</div>

The onReady() is running twice. Once in the backend and then again in the frontent. See the article [Corvid: About the Page Rendering Process](https://support.wix.com/en/article/corvid-about-the-page-rendering-process) .
