These are chat archives for COCOPi/cockpit

26th
Nov 2017
Artur
@aheinze
Nov 26 2017 01:33
@sebastianks never experienced any problems between node and cockpit
Sebastian Kolind
@sebastianks
Nov 26 2017 08:17
@aheinze okay, have you tried using express and request, instead of fetch? It might be the module and not Cockpit, since fetch works great. Maybe it should be in a documentation somewhere. I don’t know, maybe it’s also me doing it wrong :) Btw, if I want to contribute to docs and other where do I go? Also, I would like to donate to future development of cockpit, if possible? I could see cockpit as my go-to cms for client solutions.
Michelangelo Partipilo
@mpartipilo
Nov 26 2017 10:32
@sebastianks There is a docs repo for cockpit. Maybe it's the one used for the online site? Worth a check.
@sebastianks I use GatsbyJS instead of Hugo. Does pretty much the same thing, but I found Gatsby flexible enough while using it before I even gave a chance to Hugo :smile:
Sebastian Kolind
@sebastianks
Nov 26 2017 11:35
Nice. I’ll take a look at it, but for my current project I keep using Nuxt. I’ve got the calls working with fetch like you did ;)
Artur
@aheinze
Nov 26 2017 14:01
@sebastianks that would be awesome! The docs repo for cockpit is here: https://github.com/agentejo/cockpit-docs. Any donations are also welcome :+1: Either here https://www.patreon.com/user?u=3296356 or here: https://opencollective.com/cockpit - Thank you!
Sebastian Kolind
@sebastianks
Nov 26 2017 14:27
Cook. - I’ll take a look! :) keep up the good work✌🏻
Sebastian Kinz|inger
@derkinzi_twitter
Nov 26 2017 17:24
Sebastian Kolind
@sebastianks
Nov 26 2017 17:34

Shouldn't populate be equal 1?

fetch('/api/collections/get/posts?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        filter: {published:true},
        limit: 10,
        skip: 5,
        sort: {_created:-1},
        populate: 1 // resolve linked collection items
    }))
    .then(res=>res.json())
    .then(res => console.log(res));

from the documentation

Sebastian Kinz|inger
@derkinzi_twitter
Nov 26 2017 17:41
Also doesn't work with 1 unfortunately. From what I understand, the number stands for the depth (not for boolean)...
Sebastian Kolind
@sebastianks
Nov 26 2017 17:43
Ahh ok, sure.
Sebastian Kinz|inger
@derkinzi_twitter
Nov 26 2017 17:45
Ahh got though. It works with a post request and body like in your example... pretty sure I tried that before but anyways: thanks for the hint ;)
Sebastian Kolind
@sebastianks
Nov 26 2017 17:45
Hehe, np ;)
Wasn't my intention tbh, but whatever ;P
Oh, actually, fetch() with a body has to be a post ;)
Sebastian Kinz|inger
@derkinzi_twitter
Nov 26 2017 17:49
@sebastianks I'm still playing around with postman actually and I found &populate=2 as a param mentioned somewhere in a github issue... will checkout fetch once I'm heading to vue/nuxt (or probably go with axiom)
Sebastian Kolind
@sebastianks
Nov 26 2017 17:52
@derkinzi_twitter Oh okay. Same for others I think. axios is very good, and I am using Nuxt - so good! Easy to use, and built-in SSR is the main feature for me. If you're going to make your own router with Express, remember to use node-fetch instead of promise-request (node module) - for some reason promise-request has some flaw - it doesn't play nice with Cockpit.
Just a heads up ;)
Sebastian Kinz|inger
@derkinzi_twitter
Nov 26 2017 17:54
@sebastianks Ahh thanks, that's one pitfall avoided I guess ;)
Sebastian Kolind
@sebastianks
Nov 26 2017 17:54
Exactly ;)
I will contribute to the Cockpit documentation and put that in it for others to avoid ;)
Michelangelo Partipilo
@mpartipilo
Nov 26 2017 20:18
I will contribute an API client and a GatsbyJS Source Plugin :D
Artur
@aheinze
Nov 26 2017 22:50
@mpartipilo awesome! thanks :+1: