If you know anything about retrofit, please help me

Asked 2 years ago, Updated 2 years ago, 127 views

I want to get the barcode number if there is a barcode in DB when I take a barcode.

So I searched here and there and googled, but there were overwhelmingly many things that brought the entire DB.

First of all, the POJO that I made

public class Barcode {
    @SerializedName("barcode") private String barcode;

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }
}

It's like this.

And I just wanted to bring the barcode

I don't know why only get() appears and getBarcode() doesn't appear.

And the POJO I made is all String...

I looked up YouTube and other people saw "getter" on POJO, but why isn't it on me?

How do I get only the barcode number? ㅠ<

retrofit retrofit2 android

2022-09-20 20:48

1 Answers

I don't know about retrofit, but if you look at the code, It seems that response.body() is meant to load List<Barcode> instead of Barcode.

Please check as below.

response.body().get(0).getBarcode();

Thank you.


2022-09-20 20:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.