Skip to content

Commit

Permalink
chore: add develop workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rfoel committed Nov 20, 2020
1 parent 71e38fa commit 0377a04
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Develop

on:
push:
branches:
- develop

jobs:
develop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install
- run: npm test
- run: npm run lint
11 changes: 8 additions & 3 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import {
UnauthorizedError,
} from './error'

type HttpMethodTypes = 'post' | 'get'
type RequestParams = {
uri: string
params: any
}

export class Request {
request: any

constructor(apiKey: string) {
this.request = ({ uri, params }) => {
this.request = ({ uri, params }: RequestParams): void => {
const query: string = new URLSearchParams(params).toString()
return fetch(`https://api.meteostat.net/v2/${uri}?${query}`, {
headers: { 'x-api-key': apiKey },
Expand All @@ -31,7 +34,9 @@ export class Request {
params,
})

if (!response.ok) throw response
if (!response.ok) {
throw response
}

const { data } = await response.json()
return data
Expand Down

0 comments on commit 0377a04

Please sign in to comment.