Trouble loading SDK

javascript

#1

I’ve got an angular 5 app I’ve created from scratch, and I’ve done an install of @moltin/sdk in the project directory. The path resolves when in code with no problems. I can see the scoped package in my node_modules directory, and I’m importing it like this:

import {gateway as MoltinGateway} from “@moltin/sdk”;

… but when I run the application, it’s throwing me a 404 in the console when trying to load the SDK

GET http://localhost:3000/@moltin/sdk 404 (Not Found)

I cannot for the life of me figure out why it’s not finding the package when everything precompile seems to have gone off without a hitch.


#2

Hi @bdub :wave:

Are you visiting http://localhost:4000 to view the application? The address you posted won’t actually resolve to anything and provide a 404.

Inside of app.module.ts I was able to import the SDK successfully and call the Moltin.Products.All() method.

# src/app/app.module.ts

import { gateway as MoltinGateway } from '@moltin/sdk'

import { AppComponent } from './app.component'

const Moltin = MoltinGateway({
  client_id: '...'
})

Moltin.Products.All().then(data => console.log(data))

After running ng serve I was able to see inside the console my products at http://localhost:4000

If you are able to share your code, I can provide more specific advice.

I hope this helps :smile:


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.