menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Studio
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
Team

How to access response.headers with apollo-link-rest ?

November 11, 2020 at 4:45pm

How to access response.headers with apollo-link-rest ?

November 11, 2020 at 4:45pm (Edited 3 months ago)
Hi all,
I wat to use apollo-link-rest to access a rest api, however, I can not per useQuery() access the response.headers.
For example, a rest api with pagination, which put the first, prev, next, last information in the header. How can I access that?
I made an example here:
You can go to the develop tools Network tab, see the response with Headers,in link, there is the pagination information. But I have no idea, how to access the Headers....
Hier is my main code, I have no idea, how to get the response.headers.link...
const queryTodos = gql`
query Todos($page: number, $limit: number) {
todos(_page: $page, _limit: $limit)
@rest(type: "[Todo]", path: "/todos/?{args}") {
userId
id
title
completed
}
}
`;
export const Todos = () => {
const { data, loading, error } = useQuery(queryTodos, {
variables: { page: 1, limit: 3 },
fetchPolicy: "no-cache"
});
...
return (<div>...</div>)
I also asked this question in stackoverflow: https://stackoverflow.com/q/64791676/3279996 , in case you are appreciate to have more points in stackoverflow. :D
No messages yet