Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22454

Cannot find module '...' imported from '...' when trying to import functions

$
0
0

I trying to set up a Node.js backend for an Angular app I am creating.

I got the server set up, and am now trying to call a function from a different class that will hit a third-party API.

My file structure looks as follows:

Current File Structure

My server.js:

import getTournamentData from './third-party/startgg-api-service/startgg.service'; // ERROR HAPPENING HEREimport express from 'express';const app = express();app.get('/', (req, res) => {    //getTournamentData('tempest-96')    res.send('Hello World');});app.listen(3000, () => {    console.log('Server listening on Port 3000');});

My startgg.service:

import { startggVariables } from './startgg.variables';import axios from 'axios';export function getTournamentData(tourneySlug) {    let body = getTournamentDataQuery(tourneySlug);    axios.post(startggVariables.API_KEY, body)    .then(res => {        console.log(res.data)    })}function getTournamentDataQuery(tourneySlug) {    let body =  { "query": `        query TournamentQuery($slug: String) {            tournament(slug: $slug){                id                name                events {                    id                    name                }            }        }            `,"operationName": "TournamentQuery","variables": {"slug": tourneySlug}    }    return body;}

My startgg.variables:

export var startggVariables = {    API_KEY: 'https://api.start.gg/gql/alpha'}

I am getting the following error when I try to run the server:

Error From Building

I have tried the relative route from the error message, I have tried importing * from that file, and I have tried export default instead of just export, but I get the same error with all.


Viewing all articles
Browse latest Browse all 22454

Trending Articles