<% license_use" />
      <% license_use" />
        <% license_use"/>

        TechQA.

        fastify searching data from postgresql

        59 views Asked by user3227899 At 2023-10-23T13:38:28+00:00 23 October 2023 at 13:38 2025-12-18T01:06:11+00:00

        login.ejs has following code

        <input type="text" name="addUser_license" id="addUser_license" />
        
        <!-- Display the search results -->
        
        <ul>
          <% license_users.forEach((user2) => { %>
          <li><script> console.log("<%- user2.license_key %>");</script></li>
          <% }) %>
        </ul>
        

        and my ajax code is

        $("#addUser_license").blur(function () {
                let myTxt = $(this).val();
                var formData = {
                  "license_key": myTxt,
                };
                $.ajax({
                  type: "POST",
                  dataType: "JSON",
                  url: "/license",
                  data: formData,
                })
                  .done(function (response) {
                    console.log("Success: " + response.msg);
                    console.log(data);
                  })
                  .fail(function (response) {
                    console.log("Error: " + response.msg);
                    console.log(myTxt);
                    console.log(formData);
                  });
              });
        

        and my post request of server side is

        fastify.post("/license", async (request, reply) => {
          const client = await fastify.pg.connect();
          const { license_key } = request.body;
          try {
            const result = await client.query(
              'SELECT * FROM license WHERE license_key LIKE $1',
              [license_key]
            );
        
            // Pass the search results to the EJS template
            reply.view( "/login.ejs", { license_users: result.rows } );
            console.log(result.rows)
            console.log(license_key)
          } catch (err) {
            console.error(err);
            return reply.view("error.ejs");
          } finally {
            client.release();
          }
        });
          
        

        following error occcur:

        Error: undefined
        

        and this line not works. Didn't any request to return

        <li><script> console.log("<%- user2.license_key %>");</script></li>
        

        and following console results fine show

        console.log(result.rows) console.log(license_key)

        i think this line not works properly

        reply.view( "/login.ejs", { license_users: result.rows } );
        

        But i don't know why this not working? what should i do?

        jquery ajax postgresql search fastify
        Original Q&A
        0

        There are 0 answers

        Related Questions in JQUERY

        • In Datatables, start value resets to 0, when column sorting
        • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
        • window.location.href redirects but is causing problems on the webpage
        • Using JQuery Date Slider
        • Storing selected language in localStorage
        • How to stop other divs from still showing when i click a different button?
        • Check multiple values with jQuery
        • Bootstrap component does not want to render in Datatables function
        • put white spaces when entering an amount moneytype symfony
        • Trouble accessing custom header in AJAX response using jQuery in Fiware Keyrock
        • I just cant make it work, HTML, JS and Firebase error
        • Didn't declared variable still not getting any error in JavaScript
        • Move element horizontally while scrolling vertically in pure JavaScript
        • allow multi carousel in same page
        • Embedded TikTok posts / thumbnail styling issue

        Related Questions in AJAX

        • window.location.href redirects but is causing problems on the webpage
        • Js variable to php using ajax
        • TypeError: Failed to execute 'arrayBuffer' on 'Blob': Illegal invocation - Insert blob into database
        • how do I change a URL with form to include additional selection
        • why i have to put extra space in before write option selected because it show error if i don't ' option:selected'
        • Opening modal through Update button with specified ID using ajax
        • Events disappear randomly for full calendar module
        • Ajax call reloads page in FrontAccounting, a PHP ERP solution
        • Add newly added record to select2 element
        • AJAX query cascading dropdown in django
        • Failed to load resource: the server responded with a status of 403 () - SCRIPT - WordPress
        • Maintaining search and sort state across paginated results in web application
        • Getting POST 500 Internal server error while sending request via ajax call
        • Wordpress server side datatable filtering
        • Having a problem in datatables and fullcalendar scripts

        Related Questions in POSTGRESQL

        • Only the first SQL script gets executed inside Docker Postgres container
        • Compare fields in two tables
        • Hibernate ClobJdbcType bindings: what are the diferences?
        • Postgres && statement Error in Mybatis Mapper?
        • Can this query be optimized? (Choosing a random row to insert, that excludes previously inserted Rows)
        • Connection terminated unexpectedly while performing multi row insert using pg-promise
        • Processing multiple forms in nodejs and postgresql
        • How to copy data from SQLite to postgreSQL?
        • PGAdmin4 configured behind a reverse proxy but unable to connect to Postgresql server
        • Updates to pgsodium encrypted values don't use specified key_id
        • Connecting to Postgres running in a Docker container using psql
        • Can't connect to local postgresql server from my docker container
        • Django Arrayfield migration to cloud sql (Postgresql) not creating the column
        • Get list of matching keywords for each post
        • docker-compose can't reset postgresql database

        Related Questions in SEARCH

        • How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
        • Hospital route finding ai project
        • tryin to write a function that searches for SSN in a dict, and if that SSN is found, to retrieve all the data associated with that SSN
        • How the search filter from search bar works in mern?
        • Angular application loading weirdly when I add "/" at the end of URL
        • Elastic python to extract last 1hr tracing
        • How to detect if two sentences are simmilar, not in meaning, but in syllables/words?
        • I need to have a look at all my private pine scripts and filter the scripts for certain words in TRADINGVIEW
        • What is correct URL? {'quandl_error': {'code': 'QECx01', 'could not recognize URL: /api/v3/databases/WIKI/search. Please check URL and try again.'}
        • Solr 9 punctuation issue
        • Autocomplete search filter not working for dynamically added input fields in angular
        • How to correct call API search request with debounce?
        • Search in GDrive only the first 5 topics
        • How do I use sp/pnp sp.search to find all Associated sites when querying a hub site Id
        • How to apply custom analyzers on a field in Vespa schema

        Related Questions in FASTIFY

        • How to validate URL param with AJV in Fastify?
        • Is it possible to make sure a hook will run last in or after onResponse in Fastify?
        • Vitest + FastifyAutoload = FastifyError: Plugin must be a function or a promise. Received: 'object'
        • Why is my request blocked from my frontend when I specified the origin?
        • What does this mean? "Photos.js:20 Error fetching data: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON" when I'm returning JSON?
        • I don't know how to use DataSource instead of createConnection
        • Adding { parseAs: 'string } to addContentTypeParser prevents parsing from finishing
        • Can anybody provide a practical example of fastify4 + @apollo/server v4 + @fastify/websocket and Redis for gql subscriptions
        • Corrupted image uploaded to s3 but it works fine with file like .txt, .csv. I'm using NestJs, Fastyfy Multipart and serverless
        • How can I test a Fastify endpoint consuming a different endpoint?
        • Fastify setCookie not setting cookies
        • How can I configure fastify schema for multipart formdata
        • node: fast-json-stringify disable schema validation by ajv
        • How to write effective test cases with fastify using tap?
        • TypeDI and fastify-decorators issue (dependency injection)

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)
        • Privacy
        • Terms
        • Cookies
        • Homegardensmart
        • Math
        • Aftereffectstemplates