Comments (7)
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:
Lines 180 to 183 in 6b0ee2b
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.
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.
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.
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.
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.
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.
Fixed in 4.2.0
from kitsu.
Related Issues (20)
- Error: Request failed with status code 404 HOT 1
- kitsu module not found HOT 3
- return the headers with GET respose HOT 2
- JSDoc comment for `deserialise()` is inconsistent with implementation HOT 6
- Nested same relationships does not deserialize as expected HOT 9
- [object Object] is not an Option Object when defining query parameters in Vue setup context HOT 6
- Serializing an object with a relationship is not JSONAPI compliant HOT 3
- Additional axios config options in the config for all operations
- Object type checking might fail in nuxt applications HOT 5
- Dependency Dashboard
- Documentation update & Broken for relationships HOT 3
- Issue in Deserialize function: `meta` object is getting overwritten if the same reference is used multiple places. HOT 1
- Cannot call create without attributes HOT 2
- Character api HOT 1
- Deserialise method misses meta (meta: undefined) in case of relationships with links and data HOT 1
- Question: how to detect relationships HOT 4
- Sunsetting Node 14 and 16 support HOT 5
- Adding a custom scrollbar to the webpage HOT 2
- Feature: Scroll to top HOT 3
- Issue with types HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kitsu.