async await ( preferably without callbacks )
Posted: Wed Sep 04, 2024 8:02 pm
Is there a way of doing async await in SB?
- a basic to master the web -
https://forums.spiderbasic.com/
Code: Select all
Procedure.s HTTPRequestSync(Type, URL.s, Parameters.s = "")
! let type;
! switch (v_type) {
! case 0: type = "GET"; break;
! case 1: type = "POST"; break;
! case 2: type = "PUT"; break;
! case 4: type = "DELETE"; break;
! case 3: type = "PATCH"; break;
! }
! const result = $.ajax({
! url: v_url,
! type: type,
! data: v_parameters,
! async: false,
! dataType: 'json',
! });
! return result.responseText;
EndProcedure
Define Result.s
Debug "Starting"
Result = HTTPRequestSync(#PB_HTTP_Get, #PB_Compiler_Filename)
Debug "Len(Result): " + Str(Len(Result))
Debug "Finished"