How to login via API and codecept

Im new to codeceptjs + playwright. I was wondering if there is an example of how could I login as a user to the webpage via ui.

I have tried the following but it does not work for me
I can see that API request is sent and works correctly. But when page is opened then it is still asking me to login. What do I miss ?

Scenario(‘login to UI via api request’, async({I}) => {

const log =await I.sendPostRequest(‘Api/Home/57/Auth/UsernamePassword’, {

Password: “password”,
Username: “username”


sendPostRequest method eveluates in nodejs enviroment, not in browser itself.
You need to update cookies (or local storage) in browser to skip the login.
Also you can put your logic in the autoLogin plugin.

in your postRequest response must be an sessionCookie or something similar that identifies you as logged in user.

In our Tests, we grab an Cookie:sessionCookie-ID header which we add to the follow up API requests headers.

thank you for your answer