fastn
fastn copied to clipboard
Cannot resolve variable inside `fscript` function
I was trying to concatenate an integer (status) with a base URL. This was in order to redirect the user back to the home screen once the PostgreSQL Insert query had finished, and a status code would be included in the URL as a query parameter. However, an error was encountered:
thread 'actix-server worker 5' panicked at 'called `Result::unwrap()` on an `Err` value: Exception(String("ReferenceError: 'status' is not defined"))', fastn-js/src/ssr.rs:22:48
Code:
-- import: fastn/processors as pr
-- record r-data:
string name:
string email:
-- r-data data:
$processor$: pr.request-data
-- integer status:
$processor$: pr.pg
name: $data.name
email: $data.email
INSERT INTO subscriptions (name, email) VALUES ($name::VARCHAR, $email::VARCHAR);
-- ftd.redirect: $get-redirect-url(status = $status)
code: 302
-- string get-redirect-url(status):
integer status:
"/?status=" + status.get()
@Heulitig