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

[FLAG-945] Testing Research Watch API #4718

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 4 additions & 2 deletions pages/api/gfw/[...params].js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import httpProxyMiddleware from 'next-http-proxy-middleware';

import { GFW_API } from 'utils/apis';
import { GFW_API, GFW_STAGING_API } from 'utils/apis';
import { PROXIES } from 'utils/proxies';

const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV;

const GFW_API_KEY = process.env.NEXT_PUBLIC_GFW_API_KEY;

// We never use the `staging-api.resourcewatch.org`
const GFW_API_URL = GFW_API;
const GFW_API_URL = ENVIRONMENT === 'staging' ? GFW_STAGING_API : GFW_API;

// https://github.com/stegano/next-http-proxy-middleware/issues/32#issuecomment-1031015850
export const config = {
Expand Down
11 changes: 6 additions & 5 deletions services/datasets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rwRequest, dataRequest } from 'utils/request';
import { dataRequest } from 'utils/request';
import axios from 'axios';

const environmentString = () => {
const env = process.env.NEXT_PUBLIC_FEATURE_ENV;
Expand All @@ -13,9 +14,9 @@ const environmentString = () => {
};

export const getDatasets = () =>
rwRequest
axios
.get(
`/dataset?application=gfw&includes=metadata,vocabulary,layer&published=true&page[size]=9999&env=${environmentString()}${
`https://api.resourcewatch.org/dataset?application=gfw&includes=metadata,vocabulary,layer&published=true&page[size]=9999&env=${environmentString()}${
environmentString() === 'staging'
? `&filterIncludesByEnv=true&refresh=${new Date()}`
: ''
Expand All @@ -24,8 +25,8 @@ export const getDatasets = () =>
.then((res) => res?.data);

export const getDatasetMeta = () =>
rwRequest
.get('glad-alerts/latest/')
axios
.get('https://api.resourcewatch.org/glad-alerts/latest/')
.then((res) => res?.data)
.then((data) => {
const latestDate = data?.data[0]?.attributes?.date;
Expand Down
Loading