diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7c68b07 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# https://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.eslintrc.json b/.eslintrc.json index 84cef4f..7f8e075 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,28 +1,29 @@ { - "parserOptions": { - "ecmaVersion": 5 - }, + "env": { "commonjs": true }, "extends": "eslint:recommended", - "env": { - "commonjs": true - }, + "parserOptions": { "ecmaVersion": 5 }, "rules": { - "strict": [2, "global"], - "block-scoped-var": 2, - "consistent-return": 2, - "eqeqeq": [2, "smart"], - "guard-for-in": 2, - "no-caller": 2, - "no-extend-native": 2, - "no-loop-func": 2, - "no-new": 2, - "no-param-reassign": 2, - "no-return-assign": 2, - "no-unused-expressions": 2, - "no-use-before-define": 2, - "radix": [2, "always"], - "indent": [2, 2], - "quotes": [2, "double"], - "semi": [2, "always"] + "block-scoped-var": "error", + "consistent-return": "error", + "eqeqeq": "error", + "guard-for-in": "error", + "no-bitwise": "error", + "no-caller": "error", + "no-extra-parens": "off", + "no-extend-native": "error", + "no-loop-func": "error", + "no-new": "error", + "no-param-reassign": "error", + "no-return-assign": "error", + "no-sequences": "error", + "no-unused-expressions": "error", + "no-use-before-define": "error", + "no-undef": "error", + "no-eq-null": "error", + "radix": ["error", "always"], + "indent": ["error", 2, { "SwitchCase": 1 }], + "quotes": ["error", "double"], + "semi": ["error", "always"], + "strict": ["error", "global"] } } diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..b79b995 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,19 @@ +--- +name: Bug report +about: Report an issue +title: "" +labels: bug +assignees: "" +--- + +**Describe the bug** +A clear and concise description of the bug. + +**To Reproduce** +A minimal code example (preferably a runnable example on [Try PureScript](https://try.purescript.org)!) or steps to reproduce the issue. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/change-request.md b/.github/ISSUE_TEMPLATE/change-request.md new file mode 100644 index 0000000..a2ee685 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/change-request.md @@ -0,0 +1,21 @@ +--- +name: Change request +about: Propose an improvement to this library +title: "" +labels: "" +assignees: "" +--- + +**Is your change request related to a problem? Please describe.** +A clear and concise description of the problem. + +Examples: + +- It's frustrating to have to [...] +- I was looking for a function to [...] + +**Describe the solution you'd like** +A clear and concise description of what a good solution to you looks like, including any solutions you've already considered. + +**Additional context** +Add any other context about the change request here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..c47a263 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: PureScript Discourse + url: https://discourse.purescript.org/ + about: Ask and answer questions here. + - name: Functional Programming Slack + url: https://functionalprogramming.slack.com + about: For casual chat and questions (use https://fpchat-invite.herokuapp.com to join). diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d8780f7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +**Description of the change** +Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR. + +--- + +**Checklist:** + +- [ ] Added the change to the changelog's "Unreleased" section with a link to this PR and your username +- [ ] Linked any existing issues or proposals that this pull request should close +- [ ] Updated or added relevant documentation in the README and/or documentation directory +- [ ] Added a test for the contribution (if applicable) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0b3ca67 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up PureScript toolchain + uses: purescript-contrib/setup-purescript@main + + - name: Cache PureScript dependencies + uses: actions/cache@v2 + with: + key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }} + path: | + .spago + output + + - name: Set up Node toolchain + uses: actions/setup-node@v1 + with: + node-version: "12.x" + + - name: Cache NPM dependencies + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install NPM dependencies + run: npm install + + - name: Build the project + run: npm run build + + - name: Run tests + run: npm run test diff --git a/.gitignore b/.gitignore index aac6732..5a54e2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,13 @@ -/.* -!/.gitignore -!/.github -!/.travis.yml +.* +!.gitignore +!.github +!.editorconfig +!.eslintrc.json -# Dependencies -bower_components -node_modules - -# Generated files output -dce-output generated-docs +bower_components -# Lockfiles +node_modules package-lock.json *.lock - -# Extra files -!/.eslintrc.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6da455e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: node_js -dist: trusty -sudo: required -node_js: stable -env: - - PATH=$HOME/purescript:$PATH -install: - - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) - - curl --location --output $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz - - tar -xvf $HOME/purescript.tar.gz -C $HOME/ - - chmod a+x $HOME/purescript - - npm install -g bower - - npm install - - bower install --production -script: - - npm run -s build - - bower install - - npm run -s test -after_success: - - >- - test $TRAVIS_TAG && - echo $GITHUB_TOKEN | pulp login && - echo y | pulp publish --no-push diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1499c37 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,201 @@ +# Changelog + +Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +Breaking changes (😱!!!): + +New features: + +Bugfixes: + +Other improvements: + +## [v11.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v11.0.0) - 2020-09-06 + +- Adds support for the `timeout` option in `Request` (#151) + +## [v10.1.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v10.1.0) - 2020-06-07 + +- Added `Newtype` instance for `StatusCode` (@ford-prefect) + +## [v10.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v10.0.0) - 2019-11-03 + +- Updated for latest `purescript-form-urlencoded`. +- Some helper functions were combined to accept `Maybe RequestBody` rather than having two variations of each. +- All request functions now return `Either Error _` - the `Aff` error channel is no longer used to capture errors from the `XHR` object, and the provided `Error` type captures the various possible error cases that can occur. +- `retry` was removed. + +## [v9.0.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v9.0.1) - 2019-09-05 + +- Ensure version mismatch with `purescript-form-urlencoded` does not compile, potentially resulting in runtime errors (spotted by @menelaos) +- Don't override `nodejsBaseUrl` already set in `xhr2` on node (@paul-rouse) + +## [v9.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v9.0.0) - 2019-03-11 + +- Update for latest `purescript-argonaut-core` + +## [v8.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v8.0.0) - 2019-02-23 + +- Updated `purescript-web-xhr` dependency +- Renamed functions in the `RequestHeader` / `ResponseHeader` modules to no longer prefix values with the module name + +## [v7.0.2](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v7.0.2) - 2019-02-09 + +- XHR timeouts are now caught and raised through `Aff`'s error channel (@acple) + +## [v7.0.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v7.0.1) - 2019-01-31 + +- Fixed an incorrect `request` example in the doc comments (@jhrcek) + +## [v7.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v7.0.0) - 2018-08-12 + +Lots of things were renamed in this release to better match their current functionality: + +- The `affjax` function is now `request` +- The `AffjaxRequest` record is now `Request` +- The `AffjaxResponse` record is now `Response` +- The `response` field of `Response` is now `body` +- The `Request` type is now `RequestBody` +- The `Response` type is now `ResponseFormat` +- The `Request` record now has a `responseFormat` field, rather than it being a separate argument to `request` + +(Most of the new names by @paldepind). + +Additionally, errors that occur during decoding a response no longer cause an entire request to fail. The `body` value is now `Either ResponseFormatError a`, so that other details about the response can still be inspected (status code, for example), even if the response body fails to decode. The `ResponseFormatError` value also carries the response body as a `Foreign` value, in case there is some further special handling that can be performed externally. + +## [v6.0.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v6.0.1) - 2018-08-05 + +**Documentation improvements** + +Thanks to @paldepind + +## [v6.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v6.0.0) - 2018-05-27 + +- Updated for PureScript 0.12 +- `Requestable` and `Respondable` classes have now been removed in favour of using explicit values +- `statusText` is now available in responses (@danbornside) +- The `Aff` canceller was fixed (@doolse) + +## [v5.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v5.0.0) - 2017-09-14 + +- Updated for `purescript-aff` v4.0.0. + +## [v4.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v4.0.0) - 2017-04-10 + +- Updated for PureScript 0.11 (@NasalMusician) + +## [v3.0.2](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v3.0.2) - 2016-12-01 + +- Tweaked JS to enable `affjax` to work in Electron apps (@aratama) + +## [v3.0.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v3.0.1) - 2016-11-15 + +- Fixed shadowed name warning + +## [v3.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v3.0.0) - 2016-11-01 + +- Updated dependencies for PureScript 0.10 + +## [v2.0.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v2.0.1) - 2016-09-11 + +- Fixed a bug in splitting headers #81 (@jasonzoladz) + +## [v2.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v2.0.0) - 2016-07-31 + +- Updated dependencies + +## [v1.2.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v1.2.0) - 2016-07-28 + +- Added convenience functions for `PATCH` operations (@clayrat) + +## [v1.0.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v1.0.0) - 2016-06-18 + +- Updates for the 1.0 core libraries and PureScript 0.9.x. + +## [v0.13.2](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.13.2) - 2016-05-12 + +- Update for Pursuit publishing + +## [v0.13.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.13.1) - 2016-04-10 + +- Set `purescript-dom` lower bound to ensure compatibility with psc 0.8.4 (@damncabbage) + +## [v0.13.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.13.0) - 2016-03-12 + +- Updated `purescript-aff` dependency +- Now uses types from `purescript-http-methods` and `purescript-media-types` + +## [v0.12.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.12.0) - 2016-02-26 + +- Added `withCredentials` option (@brendanhay) + +## [v0.11.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.11.0) - 2016-02-22 + +- Updated `purescript-aff` dependency + +## [v0.10.4](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.10.4) - 2016-02-12 + +- Added `Requestable` instance for `FormURLEncoded` (@zudov) + +## [v0.10.2](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.10.2) - 2016-01-30 + +- Errors rasied by `setRequestHeader` are now caught #58 (@codedmart) + +## [v0.10.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.10.1) - 2016-01-07 + +- Fixed handling of JSON-value responses #54, #55 + +## [v0.10.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.10.0) - 2015-11-20 + +- Added `Json` instance for `Requestable` and `Respondable` +- `Requestable` and `Respondable` now include an optional `MimeType` to use as the default `Content-Type` or `Accept` header. + +## [v0.9.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.9.0) - 2015-10-16 + +- Node support is now provided by `xhr2` rather than `xmlhttprequest` (fixes #44) (@stkb) + +## [v0.8.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.8.1) - 2015-10-10 + +- Added `Respondable ArrayBuffer` instance (@quephird) + +## [v0.8.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.8.0) - 2015-09-23 + +Updated dependencies + +## [v0.7.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.7.0) - 2015-08-31 + +- Updated dependencies and fixed warnings for PureScript 0.7.4 + +## [v0.5.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.5.1) - 2015-08-05 + +- Added support for node via npm package 'xmlhttprequest' (@hdgarrood) + +## [v0.4.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.4.0) - 2015-07-07 + +- Updated for PureScript 0.7 (@qxjit) + +## [v0.3.2](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.3.2) - 2015-06-08 + +- A better fix for `JSONResponse` use in `Respondable` - this fix preserves the original behaviour in custom `Respondable` instances. + +## [v0.3.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.3.1) - 2015-06-08 + +- Fixed an issue with the `Respondable Foreign` instance - IE does not support automatic reading of JSON with `responseType = "json"`. + +## [v0.3.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.3.0) - 2015-05-18 + +- Bumped `purescript-integers` dependency + +## [v0.2.1](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.2.1) - 2015-04-23 + +- `ResponseType` constructors are now exported so that custom `Respondable` instances can be declared. + +## [v0.2.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.2.0) - 2015-04-20 + +- Eliminates use of Proxy for a simpler implementation of Requestable. + +## [v0.1.0](https://github.com/purescript-contrib/purescript-affjax/releases/tag/v0.1.0) - 2015-04-20 + +- This is the first beta release of Affjax, a library designed to expose AJAX through Aff. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b51c584 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing to Affjax + +Thanks for your interest in contributing to `affjax`! We welcome new contributions regardless of your level of experience or familiarity with PureScript. + +Every library in the Contributors organization shares a simple handbook that helps new contributors get started. With that in mind, please [read the short contributing guide on purescript-contrib/governance](https://github.com/purescript-contrib/governance/blob/main/contributing.md) before contributing to this library. diff --git a/README.md b/README.md index 29498f0..d4467a4 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,28 @@ -# purescript-affjax +# Affjax -[![Latest release](http://img.shields.io/github/release/slamdata/purescript-affjax.svg)](https://github.com/slamdata/purescript-affjax/releases) -[![Build status](https://travis-ci.org/slamdata/purescript-affjax.svg?branch=master)](https://travis-ci.org/slamdata/purescript-affjax) +[![CI](https://github.com/purescript-contrib/purescript-affjax/workflows/CI/badge.svg?branch=main)](https://github.com/purescript-contrib/purescript-affjax/actions?query=workflow%3ACI+branch%3Amain) +[![Release](https://img.shields.io/github/release/purescript-contrib/purescript-affjax.svg)](https://github.com/purescript-contrib/purescript-affjax/releases) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-affjax/badge)](https://pursuit.purescript.org/packages/purescript-affjax) +[![Maintainer: garyb](https://img.shields.io/badge/maintainer-garyb-teal.svg)](https://github.com/garyb) +[![Maintainer: thomashoneyman](https://img.shields.io/badge/maintainer-thomashoneyman-teal.svg)](https://github.com/thomashoneyman) -A library taking advantage of [`purescript-aff`](https://github.com/slamdata/purescript-aff) to enable pain-free asynchronous AJAX requests and response handling. - -# Getting Started +A library taking advantage of [`aff`](https://github.com/purescript-contrib/purescript-aff) to enable pain-free asynchronous AJAX requests and response handling. ## Installation -``` -bower install purescript-affjax +Install `affjax` with [Spago](https://github.com/purescript/spago): + +```sh +spago install affjax ``` -If you are intending to use the library in a Node.js setting rather than the browser, you will need an additional dependency from `npm`: +If you are using `affjax` in a Node.js setting you will also need to install an additional NPM dependency: ``` npm install xhr2 ``` -## Introduction +## Quick start You can construct requests with the `request` function: @@ -30,7 +33,7 @@ import Prelude import Affjax as AX import Affjax.ResponseFormat as ResponseFormat -import Data.Argonaut.Core as J +import Data.Argonaut.Core (stringify, fromString) import Data.Either (Either(..)) import Data.HTTP.Method (Method(..)) import Effect.Aff (launchAff) @@ -40,7 +43,7 @@ main = void $ launchAff $ do result <- AX.request (AX.defaultRequest { url = "/api", method = Left GET, responseFormat = ResponseFormat.json }) case result of Left err -> log $ "GET /api response failed to decode: " <> AX.printError err - Right response -> log $ "GET /api response: " <> J.stringify response.body + Right response -> log $ "GET /api response: " <> stringify response.body ``` (`defaultRequest` is a record value that has all the required fields pre-set for convenient overriding when making a request.) @@ -50,21 +53,39 @@ There are also a number of helpers for common `get`, `post`, `put`, `delete`, an ```purescript import Affjax.RequestBody as RequestBody import Data.Maybe (Maybe(..)) +import Effect.Aff (launchAff_) -main = void $ launchAff $ do +main = launchAff_ do result1 <- AX.get ResponseFormat.json "/api" case result1 of Left err -> log $ "GET /api response failed to decode: " <> AX.printError err - Right response -> log $ "GET /api response: " <> J.stringify response.body + Right response -> log $ "GET /api response: " <> stringify response.body - result2 <- AX.post ResponseFormat.json "/api" (Just (RequestBody.json (J.fromString "test"))) + result2 <- AX.post ResponseFormat.json "/api" (Just (RequestBody.json (fromString "test"))) case result2 of Left err -> log $ "POST /api response failed to decode: " <> AX.printError err - Right response -> log $ "POST /api response: " <> J.stringify response.body + Right response -> log $ "POST /api response: " <> stringify response.body ``` -See the [main module documentation](https://pursuit.purescript.org/packages/purescript-affjax/docs/Affjax) for a full list of these helpers and their variations. +## Documentation + +`affjax` documentation is stored in a few places: + +1. Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-affjax). +2. Written documentation is kept in the [docs directory](./docs). +3. Usage examples can be found in [the test suite](./test). + +If you get stuck, there are several ways to get help: + +- [Open an issue](https://github.com/purescript-contrib/purescript-affjax/issues) if you have encountered a bug or problem. +- [Search or start a thread on the PureScript Discourse](https://discourse.purescript.org) if you have general questions. You can also ask questions in the `#purescript` and `#purescript-beginners` channels on the [Functional Programming Slack](https://functionalprogramming.slack.com) ([invite link](https://fpchat-invite.herokuapp.com/)). + +## Contributing + +You can contribute to `affjax` in several ways: + +1. If you encounter a problem or have a question, please [open an issue](https://github.com/purescript-contrib/purescript-affjax/issues). We'll do our best to work with you to resolve or answer it. -## Module documentation +2. If you would like to contribute code, tests, or documentation, please [read the contributor guide](./CONTRIBUTING.md). It's a short, helpful introduction to contributing to this library, including development instructions. -Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-affjax). +3. If you have written a library, tutorial, guide, or other resource based on this package, please share it on the [PureScript Discourse](https://discourse.purescript.org)! Writing libraries and learning resources are a great way to help this library succeed. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..326b337 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Affjax Documentation + +This directory contains documentation for `affjax`. If you are interested in contributing new documentation, please read the [contributor guidelines](../CONTRIBUTING.md) and [What Nobody Tells You About Documentation](https://documentation.divio.com) for help getting started. diff --git a/package.json b/package.json index 58ae3be..72c757c 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,14 @@ { "private": true, "scripts": { - "clean": "rimraf output && rimraf .pulp-cache", - "build": "eslint src && pulp build -- --censor-lib --strict", - "test": "eslint src && pulp test" + "build": "eslint src && spago build --purs-args '--censor-lib --strict'", + "test": "spago test --no-install" }, "devDependencies": { - "eslint": "^6.8.0", "body-parser": "^1.19.0", + "eslint": "^7.10.0", "express": "^4.17.1", - "pulp": "^14.0.0", - "purescript-psa": "^0.7.3", - "rimraf": "^3.0.2", + "purescript-psa": "^0.8.0", "xhr2": "^0.2.0" } } diff --git a/packages.dhall b/packages.dhall new file mode 100644 index 0000000..80f5fe6 --- /dev/null +++ b/packages.dhall @@ -0,0 +1,4 @@ +let upstream = + https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201007/packages.dhall sha256:35633f6f591b94d216392c9e0500207bb1fec42dd355f4fecdfd186956567b6b + +in upstream diff --git a/spago.dhall b/spago.dhall new file mode 100644 index 0000000..08d7e22 --- /dev/null +++ b/spago.dhall @@ -0,0 +1,22 @@ +{ name = "affjax" +, dependencies = + [ "aff" + , "argonaut-core" + , "arraybuffer-types" + , "console" + , "effect" + , "foreign" + , "form-urlencoded" + , "http-methods" + , "integers" + , "math" + , "media-types" + , "nullable" + , "psci-support" + , "refs" + , "unsafe-coerce" + , "web-xhr" + ] +, packages = ./packages.dhall +, sources = [ "src/**/*.purs", "test/**/*.purs" ] +} diff --git a/src/Affjax.js b/src/Affjax.js index 4d1468b..292e47a 100644 --- a/src/Affjax.js +++ b/src/Affjax.js @@ -48,6 +48,7 @@ exports._ajax = function () { xhr.open(options.method || "GET", fixedUrl, true, options.username, options.password); if (options.headers) { try { + // eslint-disable-next-line no-eq-null,eqeqeq for (var i = 0, header; (header = options.headers[i]) != null; i++) { xhr.setRequestHeader(header.field, header.value); }