Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix blogs in welcome page #627

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Blob = require('blob-polyfill').Blob;

import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';

import axios from 'axios';

export function app(): express.Express {
const server = express();
Expand All @@ -32,17 +32,13 @@ export function app(): express.Express {
PointerEvent: {}
};



// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
server.engine(
'html',
ngExpressEngine({
bootstrap: AppServerModule,
inlineCriticalCss: false,
providers: [
{ provide: 'document', useValue: fakeWindow.document },
],
providers: [{ provide: 'document', useValue: fakeWindow.document }]
})
);
server.use(helmet.noSniff());
Expand All @@ -52,8 +48,6 @@ export function app(): express.Express {
// Example Express Rest API endpoints
// server.get('/api/**', (req, res) => { });



// Serve static files from /browser
server.get(
'*.*',
Expand All @@ -70,7 +64,6 @@ export function app(): express.Express {
server.get('/campaign/**/recover-my-gains', getStaticFiles);
server.get('/campaign/**/verify-link', getStaticFiles);


// All regular routes use the Universal engine
server.get('/campaign/**', (req, res) => {
res.render('index', {
Expand All @@ -79,21 +72,31 @@ export function app(): express.Express {
});
});

server.use(express.json());
server.get('/getBlogs', async (req, res) => {
try {
const response = await axios.get(
'https://satt-token.com/blog/wp-json/wp/v2/posts?_embed'
);
res.json(response.data);
} catch (error) {
console.error(error);
res.status(500).send('Error occurred while fetching data');
}
});

server.get('*', getStaticFiles);

return server;
}



function run(): void {
const port = process.env.PORT || 4000;

// Start up the Node server
const server = app();
server.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);// eslint-disable-line
console.log(`Node Express server listening on http://localhost:${port}`); // eslint-disable-line
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ export class FarmWelcomeComponent implements OnInit {
this.smDevice = false;
}
}

getBlogs() {
return this.http
.get('https://satt-token.com/blog/wp-json/wp/v2/posts?_embed')
.subscribe((data) => {
this.blogs = data;
});
return this.http.get('/getBlogs').subscribe((data) => {
this.blogs = data;
});
}

goToFarmPosts() {
Expand Down