Beginner - make web requests from client or server?

I’m beginning with Meteor, but like to think I know what I’m doing with JS generally.

As an exercise, I want to write an app that has a single user form that accepts a word as input. When submitted, I want to retrieve dictionary definitions from several online dictionaries and display those to the user.

In a pure react app you’d do that all in the client, but in a Meteor app, would it be better to submit the request to the server, have the server submit the web requests and then publish the results back to the client for rendering when they arrived?

I realise there are easier ways of achieving this simple end result, but I’m doing this to learn Meteor and will add other more complex features to it as I learn, so I want to get the architecture right early on.


i would do those things server side.

Have you tried the meteor tutorials already?

The thing with Meteor is that it has what they call an isomorphic api. This means that when you call an “endpoint”, this endpoint can live on both the client and the server.

Meteor’s equivalent of an endpoint is a Meteor method. It’s essentially just a function that lives on the clientside and serverside:

  myCreateMethod(params) {
    // Do something

you can now call the method like this:'myCreateMethod', params);

My main questions would be - do you need to submit API keys to the dictionary APIs along with the requests, in which case only Server-Side will do, and also, are you able to cache the dictionary responses (according to their terms and conditions) in which case multiple clients could share the definitions, which are unlikely to change anytime soon, again this would only be possible Server-Side.

Thanks, yes I do need API keys, and I’ve realised now that it has to be server side because of CORS restrictions.

I have managed to get it working now:

  • submitting form calls a method on server
  • method calls external web API
  • method saves output into a collection
  • collection feeds through subscription back to client
  • client updates the screen
1 Like