How can I change to post method in Linking.openURL?

Viewed 203

i'm using react-native

I want to log out through Linking.openURL.

The open url address uses a service called kakao.

The homepage explains like this

URL
POST /v1/user/logout HTTP/1.1
Host: kapi.kakao.com
Authorization: Bearer {ACCESS_TOKEN}

example

       curl -v -X POST "https://kapi.kakao.com/v1/user/logout" \
      -H "Authorization: Bearer {ACCESS_TOKEN}"


      Response
    HTTP/1.1 200 OK
    Content-Type: application/json;charset=UTF-8
    {
        "id":123456789
    }

So I wrote my code like this, but when I run my code, but it is suppose to get

"id":123456789 but there is nothing And the login status persists

enter image description here

this is my code

    const Myinfo = ({navigation}) => {
      const logoutfunction = async () => {
        const ACCESS_TOKEN = await AsyncStorage.getItem('accesstoken');
        console.log('ACCESS_TOKEN:::', ACCESS_TOKEN);

            fetch('http://kapi.kakao.com/v1/user/logout', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${ACCESS_TOKEN}`,
      },
    }).then((response) => console.log(response));

      return (
        <Logout activeOpacity={0.8} onPress={() => logoutfunction}>
          <LogoutText>logout</LogoutText>
        </Logout>
      );
    };

so how can i fix my code?

0 Answers
Related