N
Novu•15mo ago
empe

Make a request to the dev.api.novu.co

How can I switch my API call from the production endpoint to the development endpoint to improve the response time?
app.post('/api/novu/event', async (req, res) => {
try {
const novu = new Novu(process.env.NOVU_API_KEY);
novu.trigger('angular-notification-center', {
to: {
subscriberId: process.env.SUBSCRIBER_ID,
},
payload: {
},
});
const data = { message: 'Event triggered successfully' };
res.json(data);
} catch (error) {
console.error(error);
res.status(500).send('Server Error');
}
});
app.post('/api/novu/event', async (req, res) => {
try {
const novu = new Novu(process.env.NOVU_API_KEY);
novu.trigger('angular-notification-center', {
to: {
subscriberId: process.env.SUBSCRIBER_ID,
},
payload: {
},
});
const data = { message: 'Event triggered successfully' };
res.json(data);
} catch (error) {
console.error(error);
res.status(500).send('Server Error');
}
});
13 Replies
Pawan Jain
Pawan Jain•15mo ago
@emilpearce Where you are writing baseurl I don't see baseurl in code snippet
empe
empe•15mo ago
Because I don't
Pawan Jain
Pawan Jain•15mo ago
oh sorry
empe
empe•15mo ago
It's the plain node.js trigger
import { Novu } from '@novu/node';

const novu = new Novu('<API_KEY>');

novu.trigger('angular-notification-center', {
to: {
subscriberId: '<REPLACE_WITH_DATA>'
},
payload: {}
});
import { Novu } from '@novu/node';

const novu = new Novu('<API_KEY>');

novu.trigger('angular-notification-center', {
to: {
subscriberId: '<REPLACE_WITH_DATA>'
},
payload: {}
});
Pawan Jain
Pawan Jain•15mo ago
const novu = new Novu('<API_KEY>',{ backendUrl: 'https://dev.api.novu.co' } ); change 2nd line to this
empe
empe•15mo ago
It doesn't seem to work for me
Pawan Jain
Pawan Jain•15mo ago
Any error screenshot?
Prosper
Prosper•15mo ago
@emilpearce does it work for you now? 👀
empe
empe•14mo ago
https://angular-novu.vercel.app/ I see that sometime the event go through, and sometimes CORS error, but I don't get the notification @unicodeveloper can you give a look?
Prosper
Prosper•14mo ago
Yeah sure. Have you figured the env situation now?
empe
empe•14mo ago
Still on it
Prosper
Prosper•14mo ago
okay, it will be nice to have that sorted fully first.
Novu_Bot
Novu_Bot•14mo ago
@unicodeveloper, you just advanced to level 11!