You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How get body of the request from fetch of a json data #1
<?lsp
if "application/json" == request:header"Content-Type" then
local jparser = ba.json.parser()
local ok,table
for data in request:rawrdr() do
ok,table=jparser:parse(data)
if not ok or table then break end
end
trace(ok, table)
if ok and table then
response:json(table)
end
response:senderror(400, "Invalid JSON")
end
?>
<html>
<script>
const data={
weekdays:
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
}
fetch(location.href, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
}).then(res => res.json())
.then(res => console.log(res));
</script>
</html>
Activity
vespadj commentedon Mar 14, 2022
... trying
It seem good
surfskidude commentedon Mar 14, 2022
Yes, use this template code: