Nodejs Replit createClient() function error

31 Views Asked by At

New to coding, learning python with Replit and building a personal project. I'm running into an error running this app (index.html, main.js, and style.css are the files) through the Replit command line using node main.js.

The error is

const db = createClient();
           ^
typeerror: createClient is not a function

Referring to the section of my main.js file of:

const { createClient } = require('@replit/database');
const axios = require('axios');

// Create a new database client
const db = createClient();

// Function to store form submissions in the database
async function storeFormData(formData) {
  try {
    // Generate a unique key for each form submission
    const key = `form_submission_${Date.now()}`;

    // Store the form data in the database
    await db.set(key, formData);
    console.log('Form data stored successfully!');
  } catch (error) {
    console.error('Error storing form data:', error);
  }
}


How do I troubleshoot this? I confirmed the @replit/database which createClient is a dependency of is installed. 
0

There are 0 best solutions below