SpeckleView data format


#1

@dimitrie so I have a question about the SpeckleView project that is nested in all clients. It appears to me that the data response is coming back in a different format than anticipated. I am getting this back when making a login request:

Notice how the response data is actually nested under res.data.resource instead of res.data This data also comes back without camel case like so:

So basically the login call would always fail to return the token since the property is actually nested under res.data.resource.apitoken notice no camel case.

I am going to guess that rest of the calls are also failing for that reason. Any ideas? I doubt that this is expected behavior.

cc: @luis


#2

This is expected behaviour, at least on the response side, see the response base defintion here. resource or resources will be populated based on what api call you request, ie. by id will bring data in resource and a query will bring data in resources.

What I’m worried is that this should’ve been handled in SpeckleView. Did you do a pull? I’m trying to check now branches, but it seems that this was pushed from my side…


#3

When I ran git submodule update --init that pulled the SpeckleCore and SpeckleView. From there on I just ran npm install and npm run build followed by npm run dev so that I can run these in a debug mode.

Now my login method looks like this:

I had to update that one line in there apiToken = res.data.resource.apitoken because the previous method was calling res.data.apiToken. I am fine fixing that, but I wasn’t sure if that’s what I was supposed to expect here.


#4

It looks like that was fixed in the repo: https://github.com/speckleworks/SpeckleView/blob/master/src/components/LoginForm.vue

I will just redo the pull to make sure that I am on the latest.


#5

i’m also a bit confused :upside_down_face: but if the latest is ok, is there an issue? this was just a stale submodule problem - which frankly frustrated me previously a lot. Maybe i’m spinning in circles around what you’re telling me though!!!

:dromedary_camel:casing let’s leave it out for now (or flag it in the core and specs), as i think that field was never camelcased’ up. yep, specs confirm it.


#6

i don’t think there is. It seems like the git submodule update --init doesn’t do a git pull when its done. I am confused myself. Sorry!


#7

ouch, that causes troubles! make sure once you do that git pull to commit in the revit repo, to set its submodule head to the correct place!

I think this is what was it, ie speckle revit was pointing to an old speckle view…


#8

Correct! Git submodules don’t automagically track branches or stay up to date. They stay at the commit that you set them to.


#9

Yeah so the way to get the latest when running that command would be to: git submodule update --recursive --remote.


#10

Assuming you want to update SpeckleCore and SpeckleView to the latest in their respective master branches, then sure!