how to save the return of an api in a variable in httparty and ruby?

58 Views Asked by At

I'm sending a POST request in an API that returns a token, how do I assign a variable to this generated value?

1

There are 1 best solutions below

0
Jörg W Mittag On

In Ruby, you assign a variable using the equal sign = binary infix assignment operator. See section 11.4.2.2.2 Single variable assignments of the ISO/IEC 30170:2012 Information technology — Programming languages — Ruby specification.

For example, to assign the result of sending the message bar to the local variable foo, you would write:

foo = bar