I am trying to create a website to do with Battlefield 1, but I need to call an API.
I have found a good API to use on battlefieldtracker. I have then found a npm package to use which does the process for you and converts it to a JSON format to make it easier to use.
This is the Battlefield Stats API...
https://github.com/MattMcFarland/battlefield-stats
and this is the express version...
https://github.com/MattMcFarland/battlefield-stats-express
Following the docs and obtaining a API Key, nothing seems to work when doing this. Is there anyway I can do this without having to use npm?
Having spoke to the creators of battlefield tracker, the request has to come from a server an then cached which would match up to the website that I want to do but when I call the api request from the express for whatever reason it comes up saying page cannot be displayed?
Here is the script..
const express = require('express');
const bodyParser = require('body-parser');
const battlefieldStats = require('battlefield-stats-express');
const app = express();
const bfs = battlefieldStats(API_KEY);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/api', bfs)
app.listen(3000);
via cmiotk
No comments:
Post a Comment