Simple login form to external site

I’m having a hard time with something that should be simple.
I am creating a form that to access an external system.

The form has only login and password inputs. I’m trying to use the corvid api for this.

Action: https://triunfoeventos.siefor.net.br/sistema/alu/logadm.php
Method: Post

How can I do this ?

Hey Guilherme,

You should find this post helpful.

Thank you!

Dara | Corvid Team

Hello Guilherme,

if you want to create just a simple log-in-form to an external site, then all you need are just 2-inputfields and a little code with an if-query + location-function.

Importing APIs

import wixLocation from 'wix-location';

Starting the “logIn_toExternalSite” - function.

export function myButton_click(event) {  } // button-event

Your function “logIn_toExternalSite”

function logIn_toExternalSite() {  } // your starting function

if-query

if ( ) {   } else {   }

All these you will need to realize your project.

Hey :raised_hand_with_fingers_splayed:

You should use the wix-fetch API to post to the endpoint.

import {fetch} from 'wix-fetch';

let email = $w('#email').value // Your email input element
let pass = $w('#pass').value // Your password input element

let url = "https://triunfoeventos.siefor.net.br/sistema/alu/logadm.php";

let options = {
    method: post,
    headers: { "Content-Type": "application/json" },
    body: {
        email: email,
        password: pass
    }
}

return fetch(url, options).then( (httpResponse) => {
    if (httpResponse.ok) {
        let result = httpResponse.json();
        return result;
    } else {
        // handle the case where the response wasn't accepted
        Promise.reject("Bad request");
    }
}).catch(err => {
    // handle the case where the fetch failed!
    Promise.reject("fetch faild!");
})

Hope this helps~!
Ahmad