Code Monkey home page Code Monkey logo

axiod's People

Contributors

bitomic avatar eladhaim22 avatar finalspy avatar maximilian5189 avatar pandres95 avatar roonie007 avatar yogeshkudikala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

axiod's Issues

Uncaught (in promise) TypeError: stream is locked.

Hey, I launch the very basic code to test if the package worked and I got this :

error: Uncaught (in promise) TypeError: stream is locked.
at new ReadableStreamDefaultReader (deno:op_crates/fetch/11_streams.js:358:15)
at acquireReadableStreamDefaultReader (deno:op_crates/fetch/11_streams.js:1029:20)
at ReadableStream.getReader (deno:op_crates/fetch/11_streams.js:553:16)
at Response.arrayBuffer (deno:op_crates/fetch/26_fetch.js:870:50)
at Response.text (deno:op_crates/fetch/26_fetch.js:858:29)
at mod.ts:192:25

code :

import axiod from "https://deno.land/x/axiod/mod.ts";

axiod.get("https://google.fr").then((response) => {
// response
console.log(response);

});

thanks

Upgrade axiod to support Deno 1.4.0

Describe the bug

Deno 1.4.0 introduced stricter checks on the import and export of types for all users using the --unstable flag. These (presumably) will be integrated with Deno stable in an upcoming release.

See relevant section in release blog post: https://deno.land/posts/v1.4#stricter-type-checks-in-code--unstablecode

To Reproduce

Import this module in a file and use deno run --unstable to execute the file.

Note there are several errors:

error: TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import {
^
    at https://deno.land/x/[email protected]/mod.ts:3:1

The import should work without throwing typescript errors relating to type imports and exports.

Package & Environment Details

$ deno --version
deno 1.4.6
v8 8.7.220.3
typescript 4.0.3

[Bug] 'config' object reference changes between 'request' and 'response' interceptors

const axiodOrAxios = typeof axiod !== 'undefined' ? axiod : typeof axios !== 'undefined' ? axios : undefined;

const client = axiodOrAxios.create({ baseURL: 'https://httpstat.us' });
let _config;
client.interceptors.request.use(config => {
    _config = config;
    return config;
});
client.interceptors.response.use(
    response => {
        console.log(_config === response.config);
        return response;
    },
    error => {
        console.log(_config === error.config);
        return Promise.reject(error);
    }
);
await client.get('/200');
await client.get('/401', { validateStatus: () => true });

Expected output (axios-like) :

true
true

Actual output :

false
false

Thanks

Didnt find my baseURL

I used axiod.create with a baseURL but i got the error "error: Uncaught URIError: relative URL without a base"
The fuction dont use my baseURL

Axiod 0.23 bug

error: Relative import path "url-join" not prefixed with / or ./ or ../ from "https://deno.land/x/[email protected]/mod.ts"
The command '/bin/sh -c deno cache --unstable server.ts' returned a non-zero code: 1
ERROR: Service 'ngombe_loan_api' failed to build : Build failed.

Any help? am forced to downgrade for it to work

[Bug] 'baseURL' ignored while using 'axiod(config)'

const axiodOrAxios = typeof axiod !== 'undefined' ? axiod : typeof axios !== 'undefined' ? axios : undefined;

const client = axiodOrAxios.create({ baseURL: 'https://httpstat.us' });
await client.get('/200');
console.log('Success');
await client({ url: '/200' });
console.log('Success');

Expected output (axios-like) :

Success
Success

Actual output :

Success
error: Uncaught (in promise) TypeError: Invalid URL
  return fetch(url, fetchRequestObject).then(async (x) => {
         ^
    at opUrlParse (deno:ext/url/00_url.js:52:26)
    at new URL (deno:ext/url/00_url.js:331:20)
    at new Request (deno:ext/fetch/23_request.js:307:27)
    at deno:ext/fetch/26_fetch.js:433:29
    at new Promise (<anonymous>)
    at fetch (deno:ext/fetch/26_fetch.js:429:20)
    at Function.request (https://deno.land/x/[email protected]/mod.ts:252:10)
    at Object.axiod (https://deno.land/x/[email protected]/mod.ts:23:16)

Thanks

responseType

Hello. The example from the readme returns an error. Problem with responseType.

Example code:

axiod({ method: "get", url: "http://bit.ly/2mTM3nY", responseType: "stream", }).then((response) => { response.data.pipe(fs.createWriteStream("ada_lovelace.jpg")); });

Error:

[ERROR]: Argument of type '{ method: string; url: string; responseType: string; }' is not assignable to parameter of type 'string | IRequest'. Object literal may only specify known properties, and 'responseType' does not exist in type 'IRequest'.

Consider URLSearchParams

Hi,

at the moment FormData is supported as body, and is handed to fetch without modification (mod.ts:78).

How about doing the same for URLSearchParams? In fetch both types are treated differently, e.g. for URLSearchParams the content-type header is set to application/x-www-form-urlencoded;charset=UTF-8, whereas FormData is treated as multipart/form-data. So in my opinion it would make sense to consider these scenarios in axiod as well. What do you think?

Response's header seems empty

Hi, thanks for the nice project!

const resp = await axiod({
    url: ...,
    method: 'GET',
    headers: {
        ...
    }
})

console.log(resp.headers['content-type'])

It logs undefined.
The actual response in the Network tab clearly has keys and values

Release new version

Hello, I think that the latest versions are not published on the deno land registry.

For example, here is an example of code where the queryParams are passed via the params parameter:

async function fetchArtworks() {
  const params = {
    fields: 'id,title',
    page: 10
  }
  const config = {
    url: `https://api.artic.edu/api/v1/artworks`,
    method: "get" as const,
    params,
  };

  const res = await axiod.request(config);
  console.log('res', res)
  return res.data;
}

void fetchArtworks()

When I run it with the import:

import axiod from "https://deno.land/x/axiod/mod.ts";

all fields are returned and the page is not the right one.

However, when I use the import:

import axiod from "https://raw.githubusercontent.com/roonie007/axiod/master/mod.ts";

it works correctly.

The last release is from August 2020 and the commit that fixes the problem is from November 2020. Is there any plan to publish the latest versions on the deno land registry ?

graphql request

Is it possible to make a GraphQL request like

{
  users {
    id
  }
}

302 redirects fail

I don't know if this is a bug or I'm using it wrong:

import axiod from "https://deno.land/x/axiod/mod.ts";

await axiod.get("https://httpbin.org/redirect/:1")
console.log("Test")

Results:

โžœ deno run --allow-all ./main.ts

error: Uncaught TypeError: stream is locked.
    at new ReadableStreamDefaultReader (deno:op_crates/fetch/11_streams.js:358:15)
    at acquireReadableStreamDefaultReader (deno:op_crates/fetch/11_streams.js:1029:20)
    at ReadableStream.getReader (deno:op_crates/fetch/11_streams.js:553:16)
    at Response.arrayBuffer (deno:op_crates/fetch/26_fetch.js:870:50)
    at Response.text (deno:op_crates/fetch/26_fetch.js:858:29)
    at mod.ts:192:25
    at async main.ts:13:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.