title: TypeError: _services_login__WEBPACK_IMPORTED_MODULE_0__.login is not a function
body: <p>Can anyone please see what is wrong here? Started building an app and got stuck in the beginning...</p>
  <p>Getting this error when triggering <code>loginToSpotify()</code>:</p>
  <pre><code>TypeError: _services_login__WEBPACK_IMPORTED_MODULE_0__.login is not a function
      at loginToSpotify (Login.js:6:1)
      at onClick (Login.js:15:1)
      at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
      at invokeGuardedCallback (react-dom.development.js:4277:1)
      at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:1)
      at executeDispatch (react-dom.development.js:9041:1)
      at processDispatchQueueItemsInOrder (react-dom.development.js:9073:1)
      at processDispatchQueue (react-dom.development.js:9086:1)
      at dispatchEventsForPlugins (react-dom.development.js:9097:1)
  </code></pre>
  <p><strong>index.js</strong></p>
  <pre><code>import ReactDOM from 'react-dom/client'
  import App from './App'
  
  ReactDOM.createRoot(document.getElementById('root')).render(&lt;App /&gt;)
  </code></pre>
  <p><strong>App.js</strong></p>
  <pre><code>import Login from './pages/Login'
  
  const App = () =&gt; {
    return (
      &lt;&gt;
        &lt;Login /&gt;
      &lt;/&gt;
    )
  }
  
  export default App
  </code></pre>
  <p><strong>Login.js</strong></p>
  <pre><code>import loginService from '../services/login'
  
  const Login = () =&gt; {
    const loginToSpotify = async () =&gt; {
      try {
        const response = await loginService.login()
      } catch (err) {
        console.log(err)
      }
    }
  
    return (
      &lt;&gt;
        &lt;div&gt;
          &lt;button onClick={() =&gt; loginToSpotify()}&gt;Login using Spotify&lt;/button&gt;
        &lt;/div&gt;
      &lt;/&gt;
    )
  }
  
  export default Login
  </code></pre>
  <p><strong>login.js</strong></p>
  <pre><code>import axios from 'axios'
  
  const login = async () =&gt; {
    const response = await axios.post('/login')
  
    return response.data
  }
  
  export default { login }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/jm9uc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jm9uc.jpg" alt="enter image description here" /></a></p>