sqlpage / SQLPage

Fast SQL-only data application builder. Automatically build a UI on top of SQL queries.
https://sql-page.com
MIT License
1.66k stars 99 forks source link

Issue when using the sqlpage.fetch function #701

Closed alexisrc1 closed 1 week ago

alexisrc1 commented 1 week ago

Introduction

I get this error image

when callign the fetch function

To Reproduce

set email_send_result = sqlpage.fetch(
  'https://api.sendgrid.com/v3/mail/send',
  'POST',
 json_build_object(
  'personalizations', json_build_array(
    json_build_object(
      'to', json_build_array(
        json_build_object('email', 'recipient@example.com')
      )
    )
  ),
  'from', json_build_object('email', 'sender@example.com'),
  'subject', 'Test Email',
  'content', json_build_array(
    json_build_object('type', 'text/plain', 'value', 'Hello, this is a test email.')
  )
)
)

Version information

lovasoa commented 1 week ago

Thanks for reporting ! This is a bug in SQLPage. I'm working on it. In the meantime, you should be able to get this working by doing this in two steps:

set http_request = json_build_object(
  'method', 'POST',
  'url', 'http://localhost:62802/post',
  'body', json_build_object(
    'personalizations', json_build_array(
      json_build_object(
        'to', json_build_array(
          json_build_object('email', 'recipient@example.com')
        )
      )
    ),
    'from', json_build_object('email', 'sender@example.com'),
    'subject', 'Test Email',
    'content', json_build_array(
      json_build_object('type', 'text/plain', 'value', 'Hello, this is a test email.')
    )
  )
);

set email_send_result = sqlpage.fetch($http_request);