N
Novu•2y 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•2y ago
@emilpearce Where you are writing baseurl I don't see baseurl in code snippet
empe
empeOP•2y ago
Because I don't
Pawan Jain
Pawan Jain•2y ago
oh sorry
empe
empeOP•2y 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•2y ago
const novu = new Novu('<API_KEY>',{ backendUrl: 'https://dev.api.novu.co' } ); change 2nd line to this
empe
empeOP•2y ago
It doesn't seem to work for me
Pawan Jain
Pawan Jain•2y ago
Any error screenshot?
Prosper
Prosper•2y ago
@emilpearce does it work for you now? 👀
empe
empeOP•2y 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•2y ago
Yeah sure. Have you figured the env situation now?
empe
empeOP•2y ago
Still on it
Prosper
Prosper•2y ago
okay, it will be nice to have that sorted fully first.
Novu_Bot
Novu_Bot•2y ago
@unicodeveloper, you just advanced to level 11!
Want results from more Discord servers?
Add your server