vdavid / node-mautic Goto Github PK
View Code? Open in Web Editor NEWNode.js Mautic API with ES6+async/await
License: Apache License 2.0
Node.js Mautic API with ES6+async/await
License: Apache License 2.0
Are there any known issues with using Mautic 3? I've been doing some testing and my api calls are failing with a "SyntaxError: Unexpected token < in JSON at position 0"
I'm not sure if that has anything to do with this library, but I thought I would reach out to check.
I do get this error: console.warning is not a function
Hi there, I'm running into the error
MAUTIC | Mautic API error. |
Error: MAUTIC | Mautic API error. |
at MauticConnector._callApi (/Users/djshine/Desktop/Side/cm-master/node_modules/node-mautic/MauticConnector.js:97:19)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
When making any API call, I have tried to change the logLevel
to both error
and 'verbose' and I don't receive any other log information on what this error is. I'm guessing this is related with the authentication since none of the requests are working - i'm positive the config is correct in terms of the mautic domain and the username and password
Here is a safe version of the MauticConnector object:
const mauticConnector = new MauticConnector({ apiUrl: "https://mautic.chosenmasters.com", username: "dj", password: "123456", enableErrorLogging: true, logLevel: 'error' });
I am trying this from localhost would that make any difference?
I appreciate any help, thanks!
Hi,
Following the Mautic api, companies.listContactCompanies should accept Query Parameters.
Thanks in advance
Hello @vdavid
I am trying to connect mautic through API but not successful. Can you please help?
I also used axios to test but not successful. The only thing it works is to make request via curl.
curl -v -X GET https://username:password@--url--
Below is my code
const mauticConnector = require('node-mautic');
let mautic = new mauticConnector({
apiUrl: "--url--",
username: "username",
password: "password",
timeoutInSeconds: 10
})
mautic.contacts.listContacts().then((res) => {
console.log("Successful")
console.log(res)
}).catch((err) => {
console.log("Error: " + err)
})
Here is the response:
Error: FetchError: request to https://-- url --/api/contacts failed, reason: connect ECONNREFUSED 174.138.0.0:443
Thank you
I'm confused. https://www.npmjs.com/package/node-mautic states the project version is 1.1.0.
Installing using npm install node-mautic does, in fact, install a version 1.1.0.
An examination of the node_modules/node-mautic package.json file does indeed show version 1.1.0 as the last line in the package.json file. It has a single dependency: node-fetch.
All good. HOWEVER. The github repo that nodejs.com points to (this repo) contains a tip package.json with a version number of 1.0.3. (on line 3). The dependency listed is for request instead of node-fetch.
What am I missing. I'm looking for the source code for 1.1.0 and I'm not finding it.
LIST CONTACT FIELDS is missing the query parameters: https://developer.mautic.org/#get-field
Is it possible to add a config flag of maybe verbose
or debug
to prevent console logs?
It's also currently causing an error due to the .map
failing on the error object.
Quick fix would be to add multiple options but this could be made even safer with a type check before attempting to map.
const logMessage = 'MAUTIC | Mautic API error. | ' + (body.errors || result.errors || []).map(error => error.code + ': ' + error.message).join(', ');
console.log(logMessage);
throw new Error(logMessage);
Currently, I've just wrapped all requests in a try/catch to prevent bubbling up the stack, but this means I lose any context about an error which is not ideal.
I believe this library is missing the contact batch endpoints.
Hi,
I don't know if it is a bug or not but getContactByEmailAddress
seems not working in my side. It returns the full contacts list.
my code :
const email = await mauticConnector.contacts.getContactByEmailAddress(
'email:myemail'
);
I tried using postman to call my server directly with /api/contacts?search=myemail
and I got the right data
Mautic: v2.16.2
Thanks in advance
Hi David
First of all, thank you for your package!
With Node 18, fetch
is native built in. I know, this would be breaking change to replace it, but as Node 18 is now the current LTS, it would be an option to think about itβ¦
Hi David,
Thank you for maintaining and making available this package. It's very helpful.
We found that in some cases for the editing contact request /PATCH /contacts/ID/edit
we would like to turn off the optional overwiteWithBlank
parameter. Currently this is not supported with the editContact
method because it is always set to true
and overrides any supplied arguments, even if one explicitly sets overwriteContact: false
. See line:
node-mautic/MauticConnector.js
Line 275 in 643567e
I tried to create a Pull request on a new feature branch but was unable to push that to the repo to submit the PR. Please let me know if there's anything I can do for that. Thanks !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.