0

So i am trying to use this sendinblue API. It gets installed, the documentation says i need to link it to my project so i go to the package directory, the run npm link and then i go to the folder i wanna use it from and run npm link sib-api-v3-sdk which results in an error that is in the title.

i tried doing it the other way around, that doesn't work either. i am not using webpack.

var SibV3ApiSdk = require("sib-api-v3-sdk")
var defaultClient = SibApiV3Sdk.ApiClient.instance;

// Configure API key authorization: api-key
var apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix['api-key'] = "Token"

// Configure API key authorization: partner-key
var partnerKey = defaultClient.authentications['partner-key'];
partnerKey.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//partnerKey.apiKeyPrefix['partner-key'] = "Token"

var api = new SibApiV3Sdk.AccountApi()
api.getAccount().then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});
  • npm link (in package directory) make it available globally. npm link sib-api-v3-sdk (in project folder) links to now global package. Try npm unlink in project folder and then try npm link sib-api-v3-sdk in project folder – TrevTheDev Nov 03 '19 at 03:18
  • Is the sib-api-v3-sdk package directory that you are npm link'ing within your project folder/node modules/ ? - it should not be. – TrevTheDev Nov 03 '19 at 03:20
  • You can try delete project folder/node modules and then do npm install in project folder to fix any issues that may have occurred. – TrevTheDev Nov 03 '19 at 03:22
  • @TrevTheDev yes the sib-api-v3-sdk is in my project/node_modules folder. Where else should it be cause by default it gets stored in that folder. –  Nov 03 '19 at 15:08
  • I doubt you should be linking the api. Go to the sib-api folder and send command: unlink, In your project folder - delete node modules folder and then recreate with npm install. Then npm install sendinblue-api --save. Then in your project you can access it in your code via: var sendinblue = require('sendinblue-api'); – TrevTheDev Nov 04 '19 at 03:01

0 Answers0