AnWeber / httpbook

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://httpyac.github.io/
MIT License
58 stars 4 forks source link

ReferenceError - login is not defined #24

Closed dlucazeau closed 3 years ago

dlucazeau commented 3 years ago

If I run this cell:

# @name login
POST {{apiUrlAuth}}/accounts/login
Content-Type: application/json
cache-control: no-cache
{
    email: "{{email}}",
    password: "{{password}}"
}

I got a result.

But if I add this next cell

@accessToken = {{login.tokens.accessToken}}

I got the error even if I ran only the first one: "ReferenceError - login is not defined"

Tested in VSCode Version: 1.57.1 (user setup) Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48 Date: 2021-06-17T13:28:07.755Z Electron: 12.0.7 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Windows_NT x64 10.0.19043

and in insiders Version: 1.58.0-insider (user setup) Commit: bfac07cd0e374c433c2c06d6999dabf9cf9d5d29 Date: 2021-06-28T05:14:44.463Z Electron: 12.0.12 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Windows_NT x64 10.0.19043

dlucazeau commented 3 years ago

It's not a bug. It's a misunderstanding that @ref is mandatory.

And we need to isolate the assignment of the variable in its own named cell and not in the request cell.

AnWeber commented 3 years ago

It would be helpful to have the whole file. @Ref is mandatory because I can't tell if variables are not set from NodeJS scripts and therefore I currently decided not to resolve them automatically. But it is a good idea for improvement (Anweber/httpyac#43)

dlucazeau commented 3 years ago

Using @ref is not a problem for me. So it's not a bug. And it's really a good point as we can @ref variables coming from @import files.

I've worked a lot with humao.rest-client, so I have old reflexes

AnWeber commented 3 years ago

Then I close the ticket, I will look at it once as an improvement (AnWeber/httpyac#43), but at 1st glance this does not seem so clean solvable.