Git Product home page Git Product logo

Comments (7)

duk3luk3 avatar duk3luk3 commented on August 28, 2024 1

OK, yep, that works, I have no idea how I managed not to try that variant during my attempts at randomly guessing how to get it right...

So I think I've figured out the problem - could have figured that out just by staring harder at the code instead of spending hours making it debuggable, but it appears that the axios api actually changed:

https://github.com/axios/axios/blob/master/README.md#axiospatchurl-data-config

axios.patch(url[, data[, config]])

kitsu does this:

kitsu/src/index.js

Lines 180 to 183 in 6b0ee2b

const { data } = await axios.patch(url, {
data: (await serialise.apply(this, [ model, body, 'PATCH' ])).data,
headers
})

But should do this:

      const { data } = await axios.patch(url,
        {data: (await serialise.apply(this, [ model, body, 'PATCH' ])).data},
        {headers: headers}
      )

In my browserified js, this is what the working code looks like:

        var _ref2 = yield axios.patch(url,
            {data: (yield serialise.apply(_this2, [model, body, 'PATCH'])).data},
          {headers: headers}
        );

        const data = _ref2.data;

If that analysis makes sense to you, I'll be happy to make a PR.

from kitsu.

wopian avatar wopian commented on August 28, 2024

I can't seem to replicate this - request headers correctly contained application/vnd.api+json for everything I've tried.

Only change is that axios is now just imported and used directly instead of being added to the class and used internally. This shouldn't have any effect on the headers though - the Accept and Content-Type headers are added over everything else.


Also you'll want to add resourceCase: 'snake' to the initialize options - the default changed from snake_case to kebab-case in 4.x

from kitsu.

duk3luk3 avatar duk3luk3 commented on August 28, 2024

Hmm, I'll debug into this more once I am less sleep-deprived.

Is there a way to get the non-minified versions of axios and kitsu browserified with all its dependencies so I can debug this in my application?

from kitsu.

wopian avatar wopian commented on August 28, 2024

Actually - the headers were changed from content-type to Content-Type in 4.x and is dropping the content type header, but not the accept header (I may have been looking at the responses' content type header last night 😆). May be a bug in Axios though. axios/axios#86 axios/axios#89

Don't have the time to do anything until the weekend, but reverting back to creating a new instance of Axios in the class constructor may fix this.

You can use Browserify to bundle the dependencies into a single file.

from kitsu.

duk3luk3 avatar duk3luk3 commented on August 28, 2024

You can use Browserify to bundle the dependencies into a single file.

Yes, but how do I do that with the non-minified versions? My npm-fu is weak.

I tried this in a source checkout:

yarn
yarn add browserify
yarn run browserify src/ -o src_bundle.js

It runs into this:

yarn run browserify src -o src_bundle.js                                                                                                                                         ~/git/personal/kitsu
yarn run v1.3.2
$ /home/erlacher/git/personal/kitsu/node_modules/.bin/browserify src -o src_bundle.js
Error: Parsing file /home/erlacher/git/personal/kitsu/src/index.js: Unexpected token (292:8)
    at Deps.parseDeps (/home/erlacher/git/personal/kitsu/node_modules/module-deps/index.js:481:28)
    at getDeps (/home/erlacher/git/personal/kitsu/node_modules/module-deps/index.js:414:40)
    at /home/erlacher/git/personal/kitsu/node_modules/module-deps/index.js:398:32
    at ConcatStream.<anonymous> (/home/erlacher/git/personal/kitsu/node_modules/concat-stream/index.js:36:43)
    at ConcatStream.emit (events.js:164:20)
    at finishMaybe (/home/erlacher/git/personal/kitsu/node_modules/readable-stream/lib/_stream_writable.js:607:14)
    at endWritable (/home/erlacher/git/personal/kitsu/node_modules/readable-stream/lib/_stream_writable.js:615:3)
    at ConcatStream.Writable.end (/home/erlacher/git/personal/kitsu/node_modules/readable-stream/lib/_stream_writable.js:571:41)
    at DuplexWrapper.onend (/home/erlacher/git/personal/kitsu/node_modules/readable-stream/lib/_stream_readable.js:570:10)
    at Object.onceWrapper (events.js:254:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

from kitsu.

wopian avatar wopian commented on August 28, 2024

You'll need to target one of the lib files as Browserify doesn't like ES6 imports - run yarn build then yarn run browserify lib/kitsu.js -o src_bundle.js

from kitsu.

wopian avatar wopian commented on August 28, 2024

Fixed in 4.2.0

from kitsu.

Related Issues (20)

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.